我知道 CSS-loader 只是模块化你的 CSS,所以如果你导入 style.css
在你的foo.js
,每当 foo.js
运行后,它引用 style.css
这样您的元素就可以在 foo.js
中创建然后可以得到 style.css
的散列类名。那么样式加载器通常用来放style.css
进入<style>
标记您的 html,以便应用样式。
我不确定提取文本插件的意义是什么。是不是这样您就不需要样式加载器,然后您可以将所有 css 提取到一个文件中,然后通过手动在 html 中输入名称来链接到它?
最佳答案
来自documentation :
It moves all the required *.css modules in entry chunks into a separate CSS file. So your styles are no longer inlined into the JS bundle, but in a separate CSS file (styles.css). If your total stylesheet volume is big, it will be faster because the CSS bundle is loaded in parallel to the JS bundle.
关于javascript - CSS 加载器和提取文本插件用例 Webpack,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49091298/