Lumpat menyang isi utama Lumpat menyang pandhu arah docs
in English

Parcel

Sinau carane nyakup Bootstrap ing proyek sampeyan nggunakake Parcel.

Pasang Parcel

Pasang Paket Paket .

Instal Bootstrap

Instal bootstrap minangka modul Node.js nggunakake npm.

Bootstrap gumantung ing Popper , sing ditemtokake ing peerDependenciesproperti kasebut. Iki tegese sampeyan kudu nggawe manawa nambahake loro-lorone menyang package.jsonpanggunaan sampeyan npm install @popperjs/core.

Nalika kabeh wis rampung, proyek sampeyan bakal disusun kaya iki:

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

Ngimpor JavaScript

Impor JavaScript Bootstrap ing titik entri app sampeyan (biasane src/index.js). Sampeyan bisa ngimpor kabeh plugin ing siji file utawa kanthi kapisah yen sampeyan mung mbutuhake subset.

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

Ngimpor CSS

Kanggo nggunakke potensial lengkap Bootstrap lan ngatur kanggo kabutuhan, gunakake file sumber minangka bagéan saka proses bundling project.

Gawe dhewe scss/custom.scsskanggo ngimpor file Sass Bootstrap banjur ganti variabel khusus sing wis dibangun .

Mbangun app

Kalebu sadurunge tag src/index.jspenutup .</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>

Suntingpackage.json

Tambah devlan buildskrip ing package.jsonfile sampeyan.

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

Jalanake skrip dev

Aplikasi sampeyan bakal bisa diakses ing http://127.0.0.1:1234.

npm run dev

Mbangun file app

File sing dibangun ana ing build/folder kasebut.

npm run build