Rubuta labari mai tsayi game da html-webpack-plugin ya ฦunshi bayanan fasaha kaษan, amma zan yi iya ฦoฦarina don warware shi ta hanyar mataki-mataki.
Fakitin gidan yanar gizon HTML yana sauฦaฦe ฦirฦirar fayilolin HTML don hidimar dauren fakitin gidan yanar gizon ku. Wannan yana da amfani musamman ga fakitin gidan yanar gizo waษanda suka haษa da zanta a cikin sunan fayil wanda ke canza kowane tarin. Kuna iya barin plugin ษin ya samar muku da fayil ษin HTML, sanya shi ya daidaita muku hashes, da riba.
Yanzu bari mu shiga cikin maganin matsalar gama gari da zaku iya fuskanta yayin amfani da fakitin gidan yanar gizon HTML.
Matsala na kowa
Bari mu ce kuna son shigar da rubutun cikin jiki ko shugaban HTML. Wannan ya haษa da duk ฦugiya ta tsohuwa - ba abin da muke so ba.
Maganin matsalar
Anan ga kuskuren kuskuren cewa kai da tambarin jiki kawai za a iya amfani da su don allura. Za mu iya samun ฦarin zaษuษษuka ta saita zaษin allura a cikin saitin kayan aikin gidan yanar gizon HTML.
Yanzu bari mu nutse cikin wasu codeing JavaScript don misalta wannan ta hanyar da ta fi dacewa.
new HtmlWebpackPlugin({ inject: 'body', // Other configurations... })
Wannan hanya ษaya ce ta yin ta. Hakanan zaka iya allurar rubutun a cikin kai kamar haka:
new HtmlWebpackPlugin({ inject: 'head', // Other configurations... })
Bayanin Mataki-Ta-Taki na Code
1. ' allura: jiki' Wannan yana shigar da fayilolin js da aka samar a cikin kasan alamar jikin a cikin wannan yanayin musamman muna tabbatar da cewa an loda duk fayilolin lokacin da muke son fara amfani da su.
2. ' allura: kai' Wannan yana nufin cewa za a sanya rubutun a cikin shugaban HTML.
A wasu lokuta, waษannan zaษuษษukan ฦila ba su isa ba. Misali, idan muna da wuraren shigarwa da yawa kuma muna son sanya rubutun daban-daban a wurare daban-daban.
Dakunan karatu ko ayyukan da ke ciki
Fakitin Yanar Gizo shine madaidaicin tsarin bundler don aikace-aikacen JavaScript na zamani. Webpack yana ษaukar kayayyaki tare da abubuwan dogaro kuma yana haifar da kadarorin da ke wakiltar waษannan samfuran.
HtmlWebpackPlugin yana sauฦaฦa ฦirฦirar fayilolin HTML don hidimar dauren fakitin gidan yanar gizon ku. HtmlWebpack Plugin yana aiki ta farko yana samar da fayil ษin HTML, sannan shigar da rubutun fakitin yanar gizo cikin fayil ษin HTML da aka ฦirฦira.
- Shafin gidan yanar gizo
- HtmlWebpackPlugin
Kamar yadda kuke gani, a wannan tafiya ta hanyar html-webpack-plugin mun tabo abubuwa daban-daban, daga fahimtar ainihin ayyukansa, don magance matsalolin gama gari, nutsewa cikin ษarna na lambar da kuma nuna mahimman ษakunan karatu da ayyukan da ke ciki.