Asosiy tarkibga o'tish Hujjatlar navigatsiyasiga oʻtish
in English

Posilka

Parcel-dan foydalanib, loyihangizga Bootstrap-ni qanday kiritishni bilib oling.

Parselni o'rnating

Parcel Bundler ni o'rnating .

Bootstrap-ni o'rnating

Bootstrapni npm yordamida Node.js moduli sifatida o'rnating .

Bootstrap xususiyatda ko'rsatilgan Popper ga bog'liq peerDependencies. package.jsonBu shuni anglatadiki, siz ikkalasini ham foydalanishga qo'shganingizga ishonch hosil qilishingiz kerak bo'ladi npm install @popperjs/core.

Hammasi tugagach, sizning loyihangiz quyidagicha tuzilgan:

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

JavaScript import qilinmoqda

Bootstrap JavaScript-ni ilovangizning kirish nuqtasiga import qiling (odatda src/index.js). Barcha plaginlarimizni bitta faylga yoki alohida-alohida import qilishingiz mumkin, agar siz ulardan faqat bir qismini talab qilsangiz.

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

CSS import qilinmoqda

Bootstrap-ning to'liq imkoniyatlaridan foydalanish va uni ehtiyojlaringizga moslashtirish uchun manba fayllarini loyihangizni birlashtirish jarayonining bir qismi sifatida foydalaning.

Bootstrap's Sass fayllarini import qilishscss/custom.scss uchun o'zingizni yarating va keyin o'rnatilgan maxsus o'zgaruvchilarni bekor qiling .

Ilova yaratish

Yopish tegidan src/index.jsoldin qo'shing .</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>

Tahrirlashpackage.json

Faylingizga qo'shing devva buildskriptlar package.json.

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

Dev skriptini ishga tushiring

Ilovangizga kirish mumkin bo'ladi http://127.0.0.1:1234.

npm run dev

Ilova fayllarini yarating

O'rnatilgan fayllar build/papkada.

npm run build