ngwugwu
Mụta ka esi etinye Bootstrap n'ọrụ gị site na iji Parcel.
Wụnye ngwugwu
Wụnye Parcel Bundler .
Wụnye Bootstrap
Wụnye bootstrap dị ka modul Node.js site na iji npm.
Bootstrap na-adabere na Popper , nke akọwapụtara na ihe peerDependencies
onwunwe. Nke a pụtara na ị ga-enwerịrị ike ịgbakwunye ha abụọ na iji package.json
gị npm install @popperjs/core
.
Mgbe emechara ihe niile, a ga-ahazi ọrụ gị dị ka nke a:
project-name/
├── build/
├── node_modules/
│ └── bootstrap/
│ └── popper.js/
├── scss/
│ └── custom.scss
├── src/
│ └── index.html
│ └── index.js
└── package.json
Na-ebubata JavaScript
Bubata JavaScript nke Bootstrap na ntinye ngwa gị (na-emekarị src/index.js
). Ị nwere ike ibubata plugins anyị niile n'otu faịlụ ma ọ bụ iche iche ma ọ bụrụ na ịchọrọ naanị obere akụkụ nke ha.
// 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';
Na-ebubata CSS
Iji jiri ikike Bootstrap zuru oke wee hazie ya ka ọ bụrụ mkpa gị, jiri faịlụ isi mmalite dịka akụkụ nke usoro nchịkọta ọrụ gị.
Mepụta nke gị scss/custom.scss
ka ibubata faịlụ Bootstrap's Sass wee kpochapụ mgbanwe omenala arụnyere n'ime ya .
Mee ngwa
Tinye tupu mkpado src/index.js
mmechi .</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>
Deziepackage.json
Tinye dev
na build
scripts na package.json
faịlụ gị.
"scripts": {
"dev": "parcel ./src/index.html",
"prebuild": "npx rimraf build",
"build": "parcel build --public-url ./ ./src/index.html --experimental-scope-hoisting --out-dir build"
}
Gbaa edemede dev
A ga-enweta ngwa gị na http://127.0.0.1:1234
.
npm run dev
Mepụta faịlụ ngwa
Faịlụ arụrụ arụ dị na build/
folda ahụ.
npm run build