lib/middleware/webpack/config.js
function config(mode = 'production', assetDirs = [], moduleDirs = [], outputDir = false) {
  const context = resolve(__dirname, '../../../node_modules');
  const entry = _entry(Utils.castArray(assetDirs));
  const output = outputDir ? { filename: '[name].js', path: outputDir } : {};
  const removeFiles = _removeFiles(entry);
  const resolveModules = Utils.concat([context], moduleDirs);
  const devtool = mode === 'development' ? 'source-map' : false;

  return {
    mode,
    context,
    entry,
    output,
    devtool,

    module: {
      rules: [
        {
          test: /\.s[ac]ss$/,
          use: [
            { loader: MiniCssExtractPlugin.loader },
            { loader: 'css-loader', options: { url: false, sourceMap: true } },
            { loader: 'sass-loader', options: { implementation: sass, sourceMap: true } },
            { loader: 'resolve-url-loader' },
          ],
        },
      ],
    },

    plugins: [
      new MiniCssExtractPlugin({
        filename: '[name].css',
      }),
      new RemoveFilesPlugin({
        files: removeFiles,
      }),
    ],

    resolve: {
      modules: resolveModules,
    },
  };
}
function config(mode = 'production', assetDirs = [], moduleDirs = [], outputDir = false) {
  const context = resolve(__dirname, '../../../node_modules');
  const entry = _entry(Utils.castArray(assetDirs));
  const output = outputDir ? { filename: '[name].js', path: outputDir } : {};
  const removeFiles = _removeFiles(entry);
  const resolveModules = Utils.concat([context], moduleDirs);
  const devtool = mode === 'development' ? 'source-map' : false;

  return {
    mode,
    context,
    entry,
    output,
    devtool,

    module: {
      rules: [
        {
          test: /\.s[ac]ss$/,
          use: [
            { loader: MiniCssExtractPlugin.loader },
            { loader: 'css-loader', options: { url: false, sourceMap: true } },
            { loader: 'sass-loader', options: { implementation: sass, sourceMap: true } },
            { loader: 'resolve-url-loader' },
          ],
        },
      ],
    },

    plugins: [
      new MiniCssExtractPlugin({
        filename: '[name].css',
      }),
      new RemoveFilesPlugin({
        files: removeFiles,
      }),
    ],

    resolve: {
      modules: resolveModules,
    },
  };
}
function config ( mode = 'production' , assetDirs = [ ] , moduleDirs = [ ] , outputDir = false ) { const context = resolve ( __dirname , '../../../node_modules' ) ; const entry = _entry ( Utils . castArray ( assetDirs ) ) ; const output = outputDir ? { filename : '[name].js' , path : outputDir } : { } ; const removeFiles = _removeFiles ( entry ) ; const resolveModules = Utils . concat ( [ context ] , moduleDirs ) ; const devtool = mode === 'development' ? 'source-map' : false ; return { mode , context , entry , output , devtool , module : { rules : [ { test : / \.s[ac]ss$ / , use : [ { loader : MiniCssExtractPlugin . loader } , { loader : 'css-loader' , options : { url : false , sourceMap : true } } , { loader : 'sass-loader' , options : { implementation : sass , sourceMap : true } } , { loader : 'resolve-url-loader' } , ] , } , ] , } , plugins : [ new MiniCssExtractPlugin ( { filename : '[name].css' , } ) , new RemoveFilesPlugin ( { files : removeFiles , } ) , ] , resolve : { modules : resolveModules , } , } ; }
Dynamic config for Webpack

@param {string} options
@return {Object} Webpack configuration
Dynamic config for Webpack