diff options
| author | eldk <[email protected]> | 2021-02-11 07:22:20 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-02-11 08:22:20 +0200 |
| commit | 812585627239f4dd77c8cd97309138945c85ae91 (patch) | |
| tree | 5d71cdcb53cdee1ad3ac8a5c72a660f2ebf4e035 | |
| parent | 2f03e32d8cefe93a2b9684e36b3335e67682261f (diff) | |
| download | bootstrap-812585627239f4dd77c8cd97309138945c85ae91.tar.xz bootstrap-812585627239f4dd77c8cd97309138945c85ae91.zip | |
Add Parcel Bundler doc (#30909)
* Add Parcel Bundler doc
* Update parcel.md
* Improve parcel.md
Co-authored-by: XhmikosR <[email protected]>
Co-authored-by: Mark Otto <[email protected]>
| -rw-r--r-- | site/content/docs/5.0/getting-started/parcel.md | 99 | ||||
| -rw-r--r-- | site/data/sidebar.yml | 1 |
2 files changed, 100 insertions, 0 deletions
diff --git a/site/content/docs/5.0/getting-started/parcel.md b/site/content/docs/5.0/getting-started/parcel.md new file mode 100644 index 000000000..000c0d677 --- /dev/null +++ b/site/content/docs/5.0/getting-started/parcel.md @@ -0,0 +1,99 @@ +--- +layout: docs +title: Parcel +description: Learn how to include Bootstrap in your project using Parcel. +group: getting-started +toc: true +--- + +## Install Parcel + +Install [Parcel Bundler](https://en.parceljs.org/getting_started.html). + +## Install Bootstrap + +[Install bootstrap]({{< docsref "/getting-started/download#npm" >}}) as a Node.js module using npm. + +Bootstrap depends on [Popper](https://popper.js.org/), which is specified in the `peerDependencies` property. This means that you will have to make sure to add both of them to your `package.json` using `npm install popper.js`. + +When all will be completed, your project will be structured like this: + +```text +project-name/ +├── build/ +├── node_modules/ +│ └── bootstrap/ +│ └── popper.js/ +├── scss/ +│ └── custom.scss +├── src/ +│ └── index.html +│ └── index.js +└── package.json +``` + +## Importing JavaScript + +Import [Bootstrap's JavaScript]({{< docsref "/getting-started/javascript" >}}) in your app's entry point (usually `src/index.js`). You can import all our plugins in one file or separately if you require only a subset of them. + +```js +// Import all plugins +import * as bootstrap from 'bootstrap'; + +// Or import only needed plugins +import { Tooltip as Tooltip, Toast as Toast, Popover as Popover } from 'bootstrap'; + +// Or import just one +import Alert as Alert from '../node_modules/bootstrap/js/dist/alert'; +``` + +## Importing CSS + +To utilize the full potential of Bootstrap and customize it to your needs, use the source files as a part of your project's bundling process. + +Create your own `scss/custom.scss` to [import Bootstrap's Sass files]({{< docsref "/customize/sass#importing" >}}) and then override the [built-in custom variables]({{< docsref "/customize/sass#variable-defaults" >}}). + +## Build app + +Include `src/index.js` before the closing `</body>` tag. + +```html +<!doctype html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + </head> + <body> + <script src="./index.js"></script> + </body> +</html> +``` + +### Edit `package.json` + +Add `dev` and `build` scripts in your `package.json` file. + +```json +"scripts": { + "dev": "parcel ./src/index.html", + "prebuild": "npx rimraf build", + "build": "parcel build --public-url ./ ./src/index.html --experimental-scope-hoisting --out-dir build" +} +``` + +### Run dev script + +Your app will be accessible at `http://127.0.0.1:1234`. + +```sh +npm run dev +``` + +### Build app files + +Built files are in the `build/` folder. + +```sh +npm run build +``` diff --git a/site/data/sidebar.yml b/site/data/sidebar.yml index 4d7c9ff84..2c8f9b45c 100644 --- a/site/data/sidebar.yml +++ b/site/data/sidebar.yml @@ -10,6 +10,7 @@ - title: JavaScript - title: Build tools - title: Webpack + - title: Parcel - title: Accessibility - title: RFS - title: RTL |
