Construir herramientas

Aprenda a usar los scripts npm incluidos en Bootstrap para construir nuestra documentación, compilar código fuente, ejecutar pruebas y más.

Configuración de herramientas

Bootstrap usa scripts npm para su sistema de compilación. Nuestro package.json incluye métodos convenientes para trabajar con el marco, incluida la compilación de código, la ejecución de pruebas y más.

Para usar nuestro sistema de compilación y ejecutar nuestra documentación localmente, necesitará una copia de los archivos fuente de Bootstrap y Node. Siga estos pasos y debería estar listo para rockear:

  1. Descargue e instale Node.js , que usamos para administrar nuestras dependencias.
  2. De cualquier descarga fuentes de Bootstrap o tenedor repositorio de Bootstrap .
  3. Navegue hasta el /bootstrap directorio raíz y ejecute npm install para instalar nuestras dependencias locales enumeradas en package.json .
  4. Instale Ruby , instale Bundler con gem install bundler y finalmente ejecútelo bundle install . Esto instalará todas las dependencias de Ruby, como Jekyll y complementos.
    • Usuarios de Windows: lea esta guía para poner Jekyll en funcionamiento sin problemas.

Cuando termine, podrá ejecutar los diversos comandos proporcionados desde la línea de comandos.

Usando scripts npm

Our package.json includes the following commands and tasks:

Task Description
npm run dist npm run dist creates the /dist/ directory with compiled files. Uses Sass, Autoprefixer, and terser.
npm test Same as npm run dist plus it runs tests locally
npm run docs Builds and lints CSS and JavaScript for docs. You can then run the documentation locally via npm run docs-serve.

Run npm run to see all the npm scripts.

Autoprefixer

Bootstrap uses Autoprefixer (included in our build process) to automatically add vendor prefixes to some CSS properties at build time. Doing so saves us time and code by allowing us to write key parts of our CSS a single time while eliminating the need for vendor mixins like those found in v3.

We maintain the list of browsers supported through Autoprefixer in a separate file within our GitHub repository. See .browserslistrc for details.

Local documentation

Running our documentation locally requires the use of Jekyll, a decently flexible static site generator that provides us: basic includes, Markdown-based files, templates, and more. Here’s how to get it started:

  1. Run through the tooling setup above to install Jekyll (the site builder) and other Ruby dependencies with bundle install.
  2. From the root /bootstrap directory, run npm run docs-serve in the command line.
  3. Open http://localhost:9001 in your browser, and voilà.

Learn more about using Jekyll by reading its documentation.

Troubleshooting

Si tiene problemas con la instalación de dependencias, desinstale todas las versiones de dependencia anteriores (globales y locales). Luego, vuelva a ejecutar npm install .