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 peerDependencies
kwipropati. Oku kuthetha ukuba kuya kufuneka uqiniseke ukuba uzongeza zombini ekusebenziseni package.json
kwakho 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 zomthombo njengenxalenye yenkqubo yokudibanisa iprojekthi yakho.
Yenza eyakho scss/custom.scss
ukungenisa iifayile zeSass zeBootstrap kwaye emva koko ukhuphele ngaphezulu iziguquguquko ezenziweyo eyakhelweyo .
Yakha i-app
Bandakanya phambi kwethegi src/index.js
yokuvala .</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 dev
kunye build
nemibhalo package.json
kwifayile 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