Fa'ase'e ile anotusi autu Fa'ase'e ile su'ega fa'amatalaga

A'oa'o pe fa'afefea ona fa'aofi Bootstrap i lau poloketi e fa'aaoga ai le Parcel.

Fa'apipi'i Parcel

Fa'apipi'i le Fa'aputuga Fa'aputu .

Fa'apipi'i le Bootstrap

Faʻapipiʻi le bootstrap o se Node.js module e faʻaaoga ai le npm.

Bootstrap faʻalagolago i Popper , lea o loʻo faʻamaonia i totonu o le peerDependenciesmeatotino. O lona uiga e tatau ona e mautinoa e faʻaopoopo uma i latou i lau package.jsonfaʻaogaina npm install @popperjs/core.

A maeʻa mea uma, o lau poloketi o le a faʻatulagaina e pei o lenei:

project-name/
├── build/
├── node_modules/
│   └── bootstrap/
│   └── popper.js/
├── scss/
│   └── custom.scss
├── src/
│   └── index.html
│   └── index.js
└── package.json

Fa'aulufaleina o le Javascript

Fa'aulufale mai le JavaScript's Bootstrap i le mea e ulufale ai lau app (masani src/index.js). E mafai ona e fa'aulufale uma mai a matou fa'apipi'i i se faila e tasi pe tu'ueseese pe afai e te mana'omia na'o se vaega itiiti o latou.

// 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';

Fa'aulufaleina CSS

Ina ia faʻaogaina le gafatia atoatoa o Bootstrap ma faʻavasegaina i ou manaʻoga, faʻaoga faila faila o se vaega o le faʻagasologa o le faʻapipiʻiina o lau poloketi.

Fausia sau oe scss/custom.scsse fa'aulufale mai ai faila Sass a Bootstrap ona fa'asolo lea o suiga fa'ale-aganu'u ua fausia .

Fausia le app

Fa'aaofia src/index.jsa'o le'i o'o i le fa'ailoga tapuni </body>.

<!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>

Fa'atonupackage.json

Faaopoopo devma buildtusitusiga i lau package.jsonfaila.

"scripts": {
  "dev": "parcel ./src/index.html",
  "prebuild": "npx rimraf build",
  "build": "parcel build --public-url ./ ./src/index.html --experimental-scope-hoisting --out-dir build"
}

Fa'asolo dev script

E mafai ona maua lau app ile http://127.0.0.1:1234.

npm run dev

Fausia faila faila

O faila faila o loʻo i totonu o le build/faila.

npm run build