Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
423 views
in Technique[技术] by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...