in English

Mangani zida

Phunzirani momwe mungagwiritsire ntchito zolemba za Bootstrap zomwe zikuphatikizidwa ndi npm kuti mupange zolemba zathu, kuphatikiza ma code source, kuyesa mayeso, ndi zina zambiri.

Kupanga zida

Bootstrap imagwiritsa ntchito zolemba za npm pamakina ake omanga. Phukusi lathu.json limaphatikizapo njira zosavuta zogwirira ntchito ndi chimango, kuphatikiza kulemba ma code, kuyesa mayeso, ndi zina zambiri.

Kuti mugwiritse ntchito makina athu omanga ndikuyendetsa zolembedwa kwanuko, mufunika kopi ya mafayilo a Bootstrap ndi Node. Tsatirani izi ndipo muyenera kukhala okonzeka kugwedeza:

  1. Tsitsani ndikuyika Node.js , yomwe timagwiritsa ntchito kuyang'anira zomwe timadalira.
  2. Mutha tsitsani magwero a Bootstrap kapena foloko ya Bootstrap .
  3. Yendetsani ku chikwatu cha mizu /bootstrapndikuthamangira npm installkuti muyike zodalira zathu zomwe zalembedwa pa package.json .

Mukamaliza, mudzatha kuyendetsa malamulo osiyanasiyana operekedwa kuchokera pamzere wolamula.

Kugwiritsa ntchito npm scripts

Pack.json yathu ili ndi malamulo ndi ntchito zotsatirazi:

Ntchito Kufotokozera
npm run dist npm run distimapanga /dist/chikwatu ndi mafayilo ophatikizidwa. Amagwiritsa ntchito Sass , Autoprefixer , ndi terser .
npm test Imayesa zoyesa kwanuko ikathanpm run dist
npm run docs-serve Amamanga ndikuyendetsa zolembedwa kwanuko.

Thamangani npm runkuti muwone zolemba zonse za npm.

Yambani ndi Bootstrap kudzera npm ndi polojekiti yathu yoyambira! Mutu ku twbs/bootstrap-npm-starter template repository kuti muwone momwe mungamangire ndikusintha Bootstrap mu polojekiti yanu ya npm. Zimaphatikizapo Sass compiler, Autoprefixer, Stylelint, PurgeCSS, ndi Zithunzi za Bootstrap.

Sass

Bootstrap v4 imagwiritsa ntchito Node Sass kuti ipange mafayilo athu a Sass kukhala mafayilo a CSS (ophatikizidwa munjira yathu yomanga). Kuti muthe kukhala ndi CSS yopangidwa yomweyi popanga Sass pogwiritsa ntchito payipi yanu, muyenera kugwiritsa ntchito Sass compiler yomwe imathandizira zinthu zomwe Node Sass amachita. Izi ndizofunikira kuzindikira chifukwa kuyambira pa Okutobala 26, 2020, LibSass ndi mapaketi omwe adamangidwa pamwamba pake-kuphatikiza Node Sass- achotsedwa .

Ngati mukufuna zatsopano za Sass kapena kugwirizanitsa ndi miyezo yatsopano ya CSS, Dart Sass tsopano ndiyo kukhazikitsa kwakukulu kwa Sass ndipo imathandizira JavaScript API yomwe imagwirizana kwambiri ndi Node Sass (ndi zina zochepa zomwe zalembedwa patsamba la GitHub la Dart Sass ).

Timachulukitsa kulondola kwa Sass mpaka 6 (mwachikhazikitso, ndi 5 mu Node Sass) kuti tipewe zovuta ndi kuzungulira kwa msakatuli. Ngati mugwiritsa ntchito Dart Sass izi sizikhala zomwe muyenera kusintha, popeza wopangayo amagwiritsa ntchito kulondola kwa 10 ndipo pazifukwa zogwira mtima samalola kuti isinthidwe.

Autoprefixer

Bootstrap imagwiritsa ntchito Autoprefixer (yophatikizidwa munjira yathu yomanga) kuti ingowonjezera zoyambira zamalonda kuzinthu zina za CSS panthawi yomanga. Kuchita izi kumatipulumutsa nthawi ndi kachidindo potilola kuti tilembe zigawo zazikulu za CSS nthawi imodzi ndikuchotsa kufunikira kwa osakaniza ogulitsa monga omwe amapezeka mu v3.

Timasunga mndandanda wa asakatuli omwe amathandizidwa kudzera mu Autoprefixer mu fayilo ina mkati mwa GitHub yathu. Onani .browserslistrc kuti mumve zambiri.

Zolemba zakomweko

Kuyendetsa zolemba zathu kwanuko kumafuna kugwiritsa ntchito Hugo, yomwe imayikidwa kudzera pa hugo-bin npm phukusi. Hugo ndi jenereta yothamanga kwambiri komanso yowonjezera yomwe imatipatsa ife: zoyambira zimaphatikizapo, mafayilo ozikidwa pa Markdown, ma templates, ndi zina zambiri. Nayi momwe mungayambitsire:

  1. Yambitsani kukhazikitsidwa kwa zida pamwambapa kuti muyike zodalira zonse.
  2. Kuchokera pamndandanda wa mizu /bootstrap, thamangani npm run docs-servemu mzere wolamula.
  3. Tsegulani http://localhost:9001/msakatuli wanu, ndipo voilà.

Dziwani zambiri za kugwiritsa ntchito Hugo powerenga zolemba zake .

Kusaka zolakwika

Mukakumana ndi zovuta pakuyika zodalira, chotsani mitundu yonse yodalira zam'mbuyomu (zapadziko lonse lapansi komanso zam'deralo). Kenako, bwerezaninso npm install.