Parcelle
Wige uburyo washyira Bootstrap mumushinga wawe ukoresheje Parcel.
Shyiramo Parcelle
Shyiramo Parcelle Bundler .
Shyiramo Bootstrap
Shyiramo bootstrap nka Node.js module ukoresheje npm.
Bootstrap iterwa na Popper , igaragara peerDependencies
mumitungo. Ibi bivuze ko ugomba kumenya neza ko wongeyeho byombi package.json
mugukoresha npm install @popperjs/core
.
Igihe byose bizarangira, umushinga wawe uzaba wubatswe gutya:
project-name/
├── build/
├── node_modules/
│ └── bootstrap/
│ └── popper.js/
├── scss/
│ └── custom.scss
├── src/
│ └── index.html
│ └── index.js
└── package.json
Kuzana JavaScript
Kuzana JavaScript ya Bootstrap mumwanya winjira muri porogaramu (mubisanzwe src/index.js
). Urashobora gutumiza amacomeka yacu yose muri dosiye imwe cyangwa ukwayo niba ukeneye igice cyayo gusa.
// 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';
Kuzana CSS
Kugira ngo ukoreshe ubushobozi bwuzuye bwa Bootstrap hanyuma uyihindure kubyo ukeneye, koresha dosiye yinkomoko nkigice cyo guhuza umushinga wawe.
Kora ibyawe scss/custom.scss
kugirango utumize dosiye ya Sass ya Bootstrap hanyuma uhishe hejuru yubatswe muburyo bwihariye .
Kubaka porogaramu
Shyiramo src/index.js
mbere yo gusoza </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>
Hindurapackage.json
Ongeraho dev
ninyandiko build
muri package.json
dosiye yawe.
"scripts": {
"dev": "parcel ./src/index.html",
"prebuild": "npx rimraf build",
"build": "parcel build --public-url ./ ./src/index.html --experimental-scope-hoisting --out-dir build"
}
Koresha inyandiko ya dev
Porogaramu yawe irashobora kuboneka kuri http://127.0.0.1:1234
.
npm run dev
Kubaka dosiye
Amadosiye yubatswe ari build/
mububiko.
npm run build