webpack 学习经验1

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/daiqisi/article/details/72846033

今天刚折腾了webpack,这是我学习的网址http://www.runoob.com/w3cnote/webpack-tutorial.html

其中有一些坑,可能是版本不一样或者是其他方面的问题吧,loader中的!style!css会报错

module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" }
        ]
    },

这里的加载器会报错

ERROR in ./runoob1.js
Module not found: Error: Can't resolve 'css' in '/Users/love/Documents/FirstProject/web/app'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
                 You need to specify 'css-loader' instead of 'css',
                 see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed
 @ ./runoob1.js 7:0-22

在这里在加载器后面加上loader就OK了

这是修改后的代码

 module:{
    loaders:[
      {test: /\.css$/,loader:"style-loader!css-loader"}
    ]
  },


希望我的入坑经验对你有所帮助,愿圣光与你同在

猜你喜欢

转载自blog.csdn.net/daiqisi/article/details/72846033
今日推荐