Baakad
Baro sida loogu daro Bootstrap mashruucaaga adoo isticmaalaya Parcel.
Ku rakib Parcel
Ku rakib Bundler Parcel .
Ku rakib Bootstrap
Ku rakib bootstrap sida moduleka Node.js adoo isticmaalaya npm.
Bootstrap waxay kuxirantahay Popper , kaas oo lagu qeexay peerDependencies
guriga. Tani waxay ka dhigan tahay inaad hubiso inaad ku darto labadoodaba package.json
isticmaalkaaga npm install @popperjs/core
.
Marka dhammaan la dhammeeyo, mashruucaagu wuxuu u habayn doonaa sidan:
project-name/
├── build/
├── node_modules/
│ └── bootstrap/
│ └── popper.js/
├── scss/
│ └── custom.scss
├── src/
│ └── index.html
│ └── index.js
└── package.json
Soo dejinta JavaScript
Soo deji Bootstrap JavaScript ee barta laga soo galo abkaaga (sida caadiga ah src/index.js
). Waxaad ku soo dejisan kartaa dhammaan pluginsyadayada hal fayl ama si gooni ah haddii aad u baahan tahay qayb-hoosaadkooda.
// 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';
Soo dejinta CSS
Si aad uga faa'iidaysato awoodda buuxda ee Bootstrap oo aad u habaynayso baahiyahaaga, isticmaal faylasha isha qayb ka mid ah habka xidhidhiyaha mashruucaaga.
Abuur kaaga si aad u scss/custom.scss
soo dejiso Bootstrap's Sass faylalka ka bacdina meesha ka saarto doorsoomayaasha ku dhex jira .
Dhis app
Ku dar summada src/index.js
xidhitaanka ka hor </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>
Wax ka beddelpackage.json
Ku dar dev
oo build
qoraalo package.json
faylkaaga.
"scripts": {
"dev": "parcel ./src/index.html",
"prebuild": "npx rimraf build",
"build": "parcel build --public-url ./ ./src/index.html --experimental-scope-hoisting --out-dir build"
}
Orod qoraalka dev
Abkaaga waxa laga geli doona http://127.0.0.1:1234
.
npm run dev
Dhis faylasha app
Faylasha la dhisay ayaa ku jira build/
galka
npm run build