I-Webpack
Funda indlela yokufaka i-Bootstrap kuphrojekthi yakho usebenzisa i-Webpack 3.
Faka i-bootstrap njengemojuli ye-Node.js usebenzisa i-npm.
Ngenisa i-JavaScript ye-Bootstrap ngokwengeza lo mugqa endaweni yokungena yohlelo lwakho lokusebenza (ngokuvamile index.js
noma app.js
):
Kungenjalo, ungangenisa ama- plugin ngawodwana njengoba kudingeka:
I-Bootstrap incike ku- jQuery ne- Popper , lezi zichazwa ngokuthi peerDependencies
, lokhu kusho ukuthi kuzodingeka uqiniseke ukuthi uyakwengeza kokubili ekusebenziseni package.json
kwakho npm install --save jquery popper.js
.
Ukuze ujabulele amandla aphelele e-Bootstrap futhi uyenze ngendlela oyifisayo ngokwezidingo zakho, sebenzisa amafayela omthombo njengengxenye yenqubo yokuhlanganisa yephrojekthi yakho.
Okokuqala, zenzele eyakho _custom.scss
futhi usebenzise yona ukuze ukhiphe okuguquguqukayo okwakhelwe ngaphakathi . Bese, sebenzisa ifayela lakho eliyinhloko le-Sass ukungenisa okuguquguqukayo kwakho ngokwezifiso, kulandelwa yi-Bootstrap:
Ukuze i-Bootstrap ihlanganise, qiniseka ukuthi uyafaka futhi usebenzisa izilayishi ezidingekayo: sass-loader , postcss-loader nge - Autoprefixer . Ngokusetha okuncane, ukulungiselelwa kwepakethi yakho yewebhu kufanele kufake lo mthetho noma okufanayo:
Kungenjalo, ungasebenzisa i-CSS ye-Bootstrap elungele ukusetshenziswa ngokumane wengeze lo mugqa endaweni yokungena yephrojekthi yakho:
Kulokhu ungasebenzisa umthetho wakho okhona css
ngaphandle kokulungiswa okukhethekile kwe-webpack config, ngaphandle kokuthi awudingi sass-loader
nje isilayishi sesitayela kanye ne -css-loader .