Holo i ka ʻike nui Holo i ka hoʻokele docs
in English

ʻāpana

E aʻo pehea e hoʻokomo ai iā Bootstrap i kāu papahana me ka hoʻohana ʻana iā Parcel.

E hoʻouka i ka ʻāpana

E hoʻouka i ka pūʻulu ʻāpana .

E hoʻouka i ka Bootstrap

E hoʻouka i ka bootstrap ma ke ʻano he module Node.js me ka npm.

Ke hilinaʻi nei ʻo Bootstrap iā Popper , i kuhikuhi ʻia i ka peerDependencieswaiwai. 'O ia ho'i, pono 'oe e hō'oia e ho'ohui iā lāua 'elua i kāu package.jsonho'ohana 'ana npm install @popperjs/core.

Ke pau nā mea a pau, e hoʻonohonoho ʻia kāu papahana e like me kēia:

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

Ke lawe mai nei i ka JavaScript

E hoʻokomo i kā JavaScript's Bootstrap i ka helu komo o kāu polokalamu (maʻa mau src/index.js). Hiki iā ʻoe ke hoʻokomo i kā mākou plugins āpau i hoʻokahi faile a ʻokoʻa paha inā makemake ʻoe i kahi ʻāpana o lākou.

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

Ke lawe mai nei i CSS

No ka hoʻohana ʻana i ka mana piha o Bootstrap a hoʻopilikino iā ia i kāu mau pono, e hoʻohana i nā faila kumu ma ke ʻano he ʻāpana o ke kaʻina hana pūʻulu o kāu papahana.

E hana iā ʻoe iho scss/custom.scsse hoʻokomo i nā faila Sass o Bootstrap a laila e hoʻopau i nā ʻano maʻamau i kūkulu ʻia .

Hana i ka polokalamu

E hoʻokomo src/index.jsma mua o ka hōʻailona pani </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>

Hoʻoponoponopackage.json

Hoʻohui deva me buildnā palapala i kāu 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"
}

Holo i ka palapala dev

Hiki ke ʻike ʻia kāu polokalamu ma http://127.0.0.1:1234.

npm run dev

E kūkulu i nā faila app

Aia nā faila i kūkulu ʻia ma ka build/waihona.

npm run build