extract-text-webpack-plugin 3.0报错

Child extract-text-webpack-plugin node_modules/[email protected]@extract-text-web               pack-plugin/dist node_modules/[email protected]@style-loader/index.js!src/page/index/index.css:
       [0] ./node_modules/[email protected]@style-loader!./src/page/index/index.css 991 bytes {               0} [built]
       [1] ./src/page/index/index.css 214 bytes {0} [built] [failed] [1 error]
        + 2 hidden modules

    ERROR in ./src/page/index/index.css
    Module parse failed: D:\server\mmall-fe\src\page\index\index.css Unexpected token (1:4)
    You may need an appropriate loader to handle this file type.
    | body{
    |     background: #ccc;
    | }
     @ ./node_modules/[email protected]@style-loader!./src/page/index/index.css 2:14-38

报错是3.0有某些原因导致版本不匹配

重新安装插件

cnpm install --save-dev [email protected]

在webpack.config.js中需要配置文件

var Ex = require('extract-text-webpack-plugin');/*css分离打包设置*/
var Ex = require('extract-text-webpack-plugin');/*css分离打包设置*/

 module: {
        loaders:[
            {
                test: /\.css$/,
                loader: Ex.extract({
                    fallback:'style-loader',
                    use: "css-loader"
                })
            }
        ]
    },

问题已完美解决

你可能感兴趣的:(webpack)