【问题标题】:Webpack proper bootstrap loading with extract-text-webpack-plugin使用 extract-text-webpack-plugin 正确加载 Webpack
【发布时间】:2017-03-08 20:56:25
【问题描述】:

我正在尝试将 css 文件与 webpack extract-text-webpack-plugin 捆绑在一起,它适用于 int (projects)/src/assets/styles 的本地文件,但我还需要来自 node_modules 的 bootstrap.css,如果我尝试将其添加到 import b from 'bootstrap/dist/css/bootstrap.css';该插件只是抛出一个听起来像这样的错误“bootstrap.css Unexpected token (7:5) You may need a proper loader to handle this file type.”如果我添加'!style!css!'如本问题所述 Webpack Error while including bootstrap 3 它确实有效,但现在它被注入到 index.html 中,这可能会减慢整个应用程序的速度。那么如何正确地从 node_modules 加载引导样式呢?我尝试使用 copy-webpack-plugin 复制它,但复制是在加载器完成工作后执行的。那么有什么建议吗?

【问题讨论】:

  • 如果 bootstrap 被加载到 head 它会覆盖上面出现的任何文件,例如

标签: javascript twitter-bootstrap webpack


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2017-07-11
    • 2018-07-26
    • 2016-03-11
    • 2016-03-04
    • 2018-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-18
    相关资源
    最近更新 更多