Webpack 以网页包链的方式编写MinicsSextract插件

Webpack 以网页包链的方式编写MinicsSextract插件,webpack,webpack-chain,Webpack,Webpack Chain,如何在webpack链中编写以下内容 const MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = { plugins: [ new MiniCssExtractPlugin({ // Options similar to the same options in webpackOptions.output // both options are optiona

如何在webpack链中编写以下内容

const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
  plugins: [
    new MiniCssExtractPlugin({
      // Options similar to the same options in webpackOptions.output
      // both options are optional
      filename: '[name].css',
      chunkFilename: '[id].css',
    }),
  ],
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader,
            options: {
              // you can specify a publicPath here
              // by default it uses publicPath in webpackOptions.output
              publicPath: '../',
              hmr: process.env.NODE_ENV === 'development',
            },
          },
          'css-loader',
        ],
      },
    ],
  },
};
如果有一点解释的话,我想这会帮助很多人

config.plugin('css').use(MiniCssExtractPlugin, [{
       filename: '[name].css',
       chunkFilename: '[id].css',
}])
config.module.rule('css')
      .test(/\.css$/)
      .use('mini-css')
      .loader(MiniCssExtractPlugin.loader)
      .options({
           publicPath: '../',
           hmr: process.env.NODE_ENV === 'development',
       })
       .end()
       .use('css-loader')
       .loader('css-loader')