简体   繁体   English

使用extract-text-webpack-plugin正确加载Webpack引导程序

[英]Webpack proper bootstrap loading with extract-text-webpack-plugin

I am trying to bundle css files with webpack extract-text-webpack-plugin it works great with local files that are int (projects)/src/assets/styles, but I also need bootstrap.css from node_modules and if I try adding it to import b from 'bootstrap/dist/css/bootstrap.css'; 我正在尝试将css文件与webpack捆绑在一起,将extract-text-webpack-plugin与int(项目)/ src / assets / styles的本地文件配合使用,但是我还需要来自node_modules的bootstrap.css,如果我尝试添加的话从'bootstrap / dist / css / bootstrap.css'导入b; the plugin just throws an error that sounds something like this "bootstrap.css Unexpected token (7:5) You may need an appropriate loader to handle this file type." 插件只会抛出一个听起来像“ bootstrap.css意外令牌(7:5)的错误”。您可能需要适当的加载程序来处理此文件类型。 If I add '!style!css!' 如果我添加'!style!css!' as described in this question Webpack Error while including bootstrap 3 it does work, but now it is injected in index.html which may slowdown the overall app. 如这个问题所述, 虽然包含了Bootstrap 3 ,但Webpack Error确实可以工作,但是现在将它注入index.html中,这可能会使整个应用程序变慢。 So how do you correctly load the bootstrap style from node_modules? 那么,如何从node_modules正确加载引导样式? I tried copying it with copy-webpack-plugin, but the copying is performed after the loaders have done their job. 我尝试使用copy-webpack-plugin复制它,但是复制是在加载程序完成工作之后执行的。 so any suggestions? 有什么建议吗?

经过更多的研究和调试,问题出在css loader路径中,该路径指向应用程序的源目录,这就是为什么它无法访问node_modules的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM