webpack 4.1.1 -> configuration.module has an unknown property 'loaders'.

前端 未结 1 938
无人共我
无人共我 2021-02-07 01:59

I just updated webpack to 4.1.1 and when I try to run it I get the following error:

Invalid configuration object. Webpack has been initialise

相关标签:
1条回答
  • 2021-02-07 02:18

    Looked at an example loader for webpack 4.1.1:

    https://webpack.js.org/loaders/raw-loader/

    All I had to do was rename loaders to rules.

    module: {
        rules: [
            { test: /\.tsx?$/, loader: ['ts-loader'] },
            { test: /\.css$/, loader: "style-loader!css-loader" },
            {
                test: /\.scss$/, use: [{
                    loader: "style-loader" // creates style nodes from JS strings
                }, {
                    loader: "css-loader" // translates CSS into CommonJS
                }, {
                    loader: "sass-loader" // compiles Sass to CSS
                }]
            },
            { test: /\.(otf|ttf|eot|svg|woff(2)?)(\?[a-z0-9=&.]+)?$/, loader: 'file-loader?name=./Scripts/dist/[name].[ext]' }
        ]
    }
    
    0 讨论(0)
提交回复
热议问题