Source

Hulpmiddelen bouwen

Leer hoe u de meegeleverde npm-scripts van Bootstrap kunt gebruiken om onze documentatie te bouwen, de broncode te compileren, tests uit te voeren en meer.

Gereedschapsconfiguratie

Bootstrap gebruikt NPM-scripts voor het buildsysteem. Onze package.json bevat handige methoden om met het framework te werken, waaronder het compileren van code, het uitvoeren van tests en meer.

Om ons buildsysteem te gebruiken en onze documentatie lokaal uit te voeren, heb je een kopie van Bootstrap's bronbestanden en Node nodig. Volg deze stappen en je zou klaar moeten zijn om te rocken:

  1. Download en installeer Node.js , die we gebruiken om onze afhankelijkheden te beheren.
  2. Navigeer naar de hoofdmap /bootstrapen voer npm installdeze uit om onze lokale afhankelijkheden te installeren die worden vermeld in package.json .
  3. Installeer Ruby , installeer Bundler met gem install bundleren voer ten slotte uit bundle install. Hiermee worden alle Ruby-afhankelijkheden geïnstalleerd, zoals Jekyll en plug-ins.
    • Windows-gebruikers: Lees deze handleiding om Jekyll probleemloos aan de slag te krijgen.

Als u klaar bent, kunt u de verschillende opdrachten uitvoeren vanaf de opdrachtregel.

NPM-scripts gebruiken

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 UglifyJS.
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

Als u problemen ondervindt met het installeren van afhankelijkheden, verwijder dan alle eerdere versies van afhankelijkheid (algemeen en lokaal). Daarna opnieuw uitvoeren npm install.