Wɛbsaet a wɔde ahyɛ mu
Sua sɛnea wode Bootstrap bɛka wo project no ho denam Webpack 3 so.
Install bootstrap sɛ Node.js module a wode npm di dwuma.
Fa Bootstrap JavaScript no ba denam saa line yi a wode bɛka wo app no entry point ho (mpɛn pii no index.js
anaa app.js
):
Sɛnea ɛbɛyɛ a, wubetumi de plugins aba ankorankoro sɛnea ɛho hia:
Bootstrap gyina jQuery ne Popper so , wɔkyerɛkyerɛ eyinom mu sɛ peerDependencies
, eyi kyerɛ sɛ ɛsɛ sɛ wohwɛ hu sɛ wode abien no nyinaa bɛka wo package.json
dwumadie npm install --save jquery popper.js
ho .
Sɛ wopɛ sɛ wonya Bootstrap tumi nyinaa mu anigye na wosakra no ma ɛne w’ahiade hyia a, fa source files no di dwuma sɛ wo project no bundling nhyehyɛe no fã.
Nea edi kan no, yɛ w’ankasa de _custom.scss
na fa di dwuma fa built-in custom variables no so . Afei, fa wo Sass fael titiriw no fa wo custom variables no ba, na Bootstrap di akyi:
Sɛ Bootstrap bɛboaboa ano a, hwɛ hu sɛ wobɛhyehyɛ na wode loaders a ɛho hia no adi dwuma: sass-loader , postcss-loader a Autoprefixer ka ho. Sɛ wowɔ nhyehyɛe ketewaa bi a, ɛsɛ sɛ wo webpack config no de mmara yi anaa nea ɛte saa ka ho:
Sɛnea ɛbɛyɛ a, wubetumi de Bootstrap CSS a wɔasiesie sɛ wode bedi dwuma no adi dwuma denam saa nkyerɛwde yi a wode bɛka wo dwumadi no hyɛn gyinabea ho ara kwa no so:
Wɔ saa tebea yi mu no wubetumi de wo mmara a ɛwɔ hɔ dedaw no adi dwuma ama a nsakrae titiriw biara nni mu wɔ webpack config mu, gye sɛ css
wunhia style-loader ne css-loader kɛkɛ .sass-loader