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

查看:395
本文介绍了vue.js - 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

解决方案

你用的是这个叫做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的时候指定的

这篇关于vue.js - vue迁移到webpack2, 'style-loader' instead of 'style'.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆