Tsibela kumxholo ophambili Tsiba uye kukhangelo lwamaxwebhu
in English

Ipasile

Funda ukubandakanya iBootstrap kwiprojekthi yakho usebenzisa iParcel.

Faka iPasi

Faka iPasile Bundler .

Faka i-Bootstrap

Faka i-bootstrap njengemodyuli ye-Node.js usebenzisa i-npm.

I-Bootstrap ixhomekeke kwiPopper , echazwe peerDependencieskwipropati. Oku kuthetha ukuba kuya kufuneka uqiniseke ukuba uzongeza zombini ekusebenziseni package.jsonkwakho npm install @popperjs/core.

Xa zonke ziya kugqitywa, iprojekthi yakho iya kwakhiwe ngolu hlobo:

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

Ukuthathwa ngaphandle kweJavaScript

Ngenisa iJavaScript yeBootstrap kwindawo yokungena yosetyenziso lwakho (ngesiqhelo src/index.js). Ungangenisa zonke iiplagi zethu kwifayile enye okanye ngokwahlukeneyo ukuba ufuna kuphela iseti esezantsi kuzo.

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

Ukuthathwa ngaphandle kweCSS

Ukusebenzisa amandla apheleleyo eBootstrap kwaye uzenzele ngokweemfuno zakho, sebenzisa iifayile zemvelaphi njengenxalenye yenkqubo yakho yokudibanisa iprojekthi.

Yenza eyakho scss/custom.scssukungenisa iifayile zeSass zeBootstrap kwaye emva koko ubhale ngaphezulu iziguquguquki zesiko eyakhelweyo .

Yakha i-app

Bandakanya phambi kwethegi src/index.jsyokuvala .</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>

Hlelapackage.json

Yongeza devkunye buildnemibhalo package.jsonkwifayile yakho.

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

Sebenzisa iskripthi se-dev

I-app yakho iyakufumaneka http://127.0.0.1:1234.

npm run dev

Yakha iifayile zeapp

Iifayile ezakhiweyo zikwifolda build/.

npm run build