Error when I use html-loader in a web pack project

682 Views Asked by At

I am setting webpack but I have an error. It happens when I try to use html-loader, what I do when I set rules in the module in webpack.config.js file. It says there is an error in child compilation. I am trying to understand why.

Here is the error :

ERROR in child compilations (Use 'stats.children: true' resp.'-- 
     stats-children' for more details)

Here is the code (thank you for your help) :

module.exports = {
  mode: "development",
  entry: path.resolve(__dirname, './src/index.js'),
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'main.js',
  },
  module: {
    rules: [
      {
        test: /\.html$/i,
        use: [
          {
            loader: "html-loader",
            options:{
              minimize: true,
            },
          },
        ],
      },
    ],
  },
  plugins: [new HtmlWebpackPlugin({
      template: path.resolve(__dirname, './src/index.html'),
      filename: "index.html",
    })],
};

My files and folders

1

There are 1 best solutions below

2
maximus383 On

In order to solve this warning you just need to add stats.children: true in your webpack.mix.js file. First of all open your webpack.mix.js file and add the following code.

mix.webpackConfig({
    stats: {
        children: true,
    },
});