vue迁移到webpack2, 'style-loader' instead of 'style'.

vue迁移到webpack2,已按迁移文档编写配置如下

我的配置:

webpackConfig.module = {
    rules : [
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
            fallback: "style-loader",
            use: "css-loader",
            publicPath: "./dist"
        })
      }
  ]
};

版本:

    "extract-text-webpack-plugin": "^2.1.0",

还是报错:

ERROR in ./app.js
Module not found: Error: Can't resolve 'style' in '/mnt/vhost/github/easy-vue'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
                 You need to specify 'style-loader' instead of 'style'.
 @ ./app.js 3:0-54
 @ multi ./app.js

ERROR in ./app.js
Module not found: Error: Can't resolve 'style' in '/mnt/vhost/github/easy-vue'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
                 You need to specify 'style-loader' instead of 'style'.
 @ ./app.js 4:0-55
 @ multi ./app.js

ERROR in ./app.js
Module not found: Error: Can't resolve 'style' in '/mnt/vhost/github/easy-vue'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
                 You need to specify 'style-loader' instead of 'style'.
 @ ./app.js 5:0-45
 @ multi ./app.js

阅读 4.6k
1 个回答

你用的是这个叫做easy-vue的库是吧?

我看到里面这app.js里的头三句就用了style-loader的:

require('!style!css!ratchet-npm/dist/css/ratchet.css');// get ratchet
require('!style!css!font-awesome/css/font-awesome.css');// get font-awesome
require('!style!css!animate.css/animate.css');// get animate.css

要注意的是,loader不是只有在webpack配置文件里做全局配置的,而是还可以在具体require/import的时候指定的

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题