build-tools.md 3.69 KB
Newer Older
1
---
Mark Otto's avatar
Mark Otto committed
2
layout: docs
3
title: Build tools
4
description: Learn how to use Bootstrap's included npm scripts to build our documentation, compile source code, run tests, and more.
5
group: getting-started
6
toc: true
7
8
---

9
## Tooling setup
Mark Otto's avatar
Mark Otto committed
10

XhmikosR's avatar
XhmikosR committed
11
Bootstrap uses [npm scripts](https://docs.npmjs.com/misc/scripts) for its build system. Our [package.json]({{< param repo >}}/blob/v{{< param current_version >}}/package.json) includes convenient methods for working with the framework, including compiling code, running tests, and more.
12

13
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:
Mark Otto's avatar
Mark Otto committed
14

15
1. [Download and install Node.js](https://nodejs.org/en/download/), which we use to manage our dependencies.
XhmikosR's avatar
XhmikosR committed
16
2. Navigate to the root `/bootstrap` directory and run `npm install` to install our local dependencies listed in [package.json]({{< param repo >}}/blob/v{{< param current_version >}}/package.json).
17

18
When completed, you'll be able to run the various commands provided from the command line.
19

20
## Using npm scripts
21

Mark Otto's avatar
Mark Otto committed
22
Our [package.json]({{< param repo >}}/blob/v{{< param current_version >}}/package.json) includes numerous tasks for developing the project. Run `npm run` to see all the npm scripts in your terminal. **Primary tasks include:**
23

Mark Otto's avatar
Mark Otto committed
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<table class="table">
  <thead>
    <tr>
      <th>Task</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>
        <code>npm start</code>
      </td>
      <td>
        Compiles CSS and JavaScript, builds the documentation, and starts a local server.
      </td>
    </tr>
    <tr>
      <td>
        <code>npm run dist</code>
      </td>
      <td>
45
       Creates the <code>dist/</code> directory with compiled files. Requires <a href="https://sass-lang.com/">Sass</a>, <a href="https://github.com/postcss/autoprefixer">Autoprefixer</a>, and <a href="https://github.com/terser/terser">terser</a>.
Mark Otto's avatar
Mark Otto committed
46
47
48
49
50
51
52
53
54
55
56
57
      </td>
    </tr>
    <tr>
      <td>
        <code>npm test</code>
      </td>
      <td>
        Runs tests locally after running <code>npm run dist</code>
      </td>
    </tr>
    <tr>
      <td>
58
        <code>npm run docs-serve</code>
Mark Otto's avatar
Mark Otto committed
59
60
      </td>
      <td>
61
        Builds and runs the documentation locally.
Mark Otto's avatar
Mark Otto committed
62
63
64
65
      </td>
    </tr>
  </tbody>
</table>
66

67
68
## Autoprefixer

69
Bootstrap uses [Autoprefixer][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.
70

XhmikosR's avatar
XhmikosR committed
71
We maintain the list of browsers supported through Autoprefixer in a separate file within our GitHub repository. See [.browserslistrc]({{< param repo >}}/blob/v{{< param current_version >}}/.browserslistrc) for details.
72

73
74
## Local documentation

XhmikosR's avatar
XhmikosR committed
75
Running our documentation locally requires the use of Hugo, which gets installed via the [hugo-bin](https://www.npmjs.com/package/hugo-bin) npm package. Hugo is a blazingly fast and quite extensible static site generator that provides us: basic includes, Markdown-based files, templates, and more. Here's how to get it started:
76

XhmikosR's avatar
XhmikosR committed
77
1. Run through the [tooling setup](#tooling-setup) above to install all dependencies.
78
2. From the root `/bootstrap` directory, run `npm run docs-serve` in the command line.
XhmikosR's avatar
XhmikosR committed
79
3. Open `http://localhost:9001/` in your browser, and voilà.
80

XhmikosR's avatar
XhmikosR committed
81
Learn more about using Hugo by reading its [documentation](https://gohugo.io/documentation/).
82
83

## Troubleshooting
84

85
Should you encounter problems with installing dependencies, uninstall all previous dependency versions (global and local). Then, rerun `npm install`.
86
87

[autoprefixer]: https://github.com/postcss/autoprefixer