网页
综合
更新时间 2026-11-16 04:34:12
Contribute · Bootstrap v6.0
自动蜘蛛
getbootstrap.com
正文约 3484 字
Help develop Bootstrap with our documentation build scripts and tests.
Bootstrap uses npm scripts to build the documentation and compile source files. Our package.json houses these scripts for compiling code, running tests, and more. These aren’t intended for use outside our repository and documentation.
To use our build system and run our documentation locally, you’ll need a copy of Bootstrap’s source files and Node. Follow these steps and you should be ready to rock:
When completed, you’ll be able to run the various commands provided from the command line.
Our package.json includes numerous tasks for developing the project. Run npm run to see all the npm scripts in your terminal. Primary tasks include:
Use the Bootstrap npm starter project! Head to the Sass & JS example template repository to see how to build and customize Bootstrap in your own npm project. Includes Sass compiler, Autoprefixer, Stylelint, PurgeCSS, and Bootstrap Icons.
Bootstrap uses Dart Sass for compiling our Sass source files into CSS files (included in our build process), and we recommend you do the same if you’re compiling Sass using your own asset pipeline. We previously used Node Sass for Bootstrap v4, but LibSass and packages built on top of it, including Node Sass, are now deprecated.
Dart Sass uses a rounding precision of 10 and for efficiency reasons does not allow adjustment of this value. We don’t lower this precision during further processing of our generated CSS, such as during minification, but if you chose to do so we recommend maintaining a precision of at least 6 to prevent issues with browser rounding.
Bootstrap uses PostCSS to process our compiled CSS with several plugins:
Autoprefixer automatically adds vendor prefixes to CSS properties at build time. This 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. We maintain the list of browsers supported through Autoprefixer in a separate file within our GitHub repository. See .browserslistrc for details.
postcss-prefix-custom-properties adds the bs- prefix to all CSS custom properties (variables). This allows us to write clean, unprefixed variable names in our Sass source (e.g., --border-radius) that become prefixed in the compiled CSS (e.g., --bs-border-radius).
Our PostCSS configuration is located in build/postcss.config.mjs.
Our JavaScript source is written in TypeScript and lives in js/src/. We bundle it with Rolldown, the Rust-based bundler from the Vite team, and then minify the output with terser. Bootstrap v5 used Rollup and Babel for this. Rolldown strips the TypeScript types and lowers the syntax itself, so we no longer need Babel.
Rolldown does not read .browserslistrc, so build/browser-targets.mjs resolves that file at build time and converts it into the target list Rolldown expects. Both pipelines therefore honor one browser list.
We ship our own TypeScript declarations, so you do not need @types/bootstrap. Our bundler configuration is located in build/rolldown.config.mjs.
Running our documentation locally requires the use of Astro. Astro is a modern static site generator that allows us to build our documentation with a combination of Markdown and React components. Here’s how to get it started:
Learn more about using Astro by reading its documentation.
Should you encounter problems with installing dependencies, uninstall all previous dependency versions (global and local). Then, rerun npm install.
本页为82搜索生成的网页快照,内容来自站内索引;演示数据的原文链接仅作示例。