Yeqela kokuqukethwe okuyinhloko Yeqela ku-docs navigation
in English

Iphasela

Funda ukuthi ungafaka kanjani i-Bootstrap kuphrojekthi yakho usebenzisa i-Parcel.

Faka Iphasela

Faka i- Parcel Bundler .

Faka i-Bootstrap

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

I-Bootstrap incike ku- Popper , ecaciswe peerDependenciesesakhiweni. Lokhu kusho ukuthi kuzodingeka wenze isiqiniseko sokungeza zombili ekusebenziseni package.jsonkwakho npm install @popperjs/core.

Lapho konke sekuqediwe, iphrojekthi yakho izohlelwa kanje:

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

Ingenisa i-JavaScript

Ngenisa i-JavaScript ye-Bootstrap endaweni yokungena yohlelo lwakho lokusebenza (ngokuvamile src/index.js). Ungangenisa wonke ama-plugin ethu efayeleni elilodwa noma ngokuhlukene uma udinga isethi encane yawo.

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

Ingenisa i-CSS

Ukuze usebenzise amandla aphelele e-Bootstrap futhi ulenze ngokwezifiso izidingo zakho, sebenzisa amafayela omthombo njengengxenye yenqubo yokuhlanganisa iphrojekthi yakho.

Dala owakho scss/custom.scssukuze ungenise amafayela e-Bootstrap's Sass bese ubhala ngaphezulu okuguquguqukayo okwakhelwe ngaphakathi .

Yakha uhlelo lokusebenza

Faka phakathi ngaphambi 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

Engeza devkanye buildnemibhalo package.jsonkufayela lakho.

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

Qalisa iskripthi se-dev

Uhlelo lwakho lokusebenza luzofinyeleleka ngo- http://127.0.0.1:1234.

npm run dev

Yakha amafayela ohlelo lokusebenza

Amafayela akhiwe build/akufolda.

npm run build