1

Here is the code that I am using to customize the webpack config. I tried multiple ways to ignore libs from minimizer but I am unable to skip them by using plugins.

Here is the output of the build process

// This file is not going through babel transformation.
// So, we write it in vanilla JS
// (But you could use ES2015 features supported by your Node.js version)
const { resolve } = require('path')
const GlobEntriesPlugin = require('webpack-watched-glob-entries-plugin')

// const CopyPlugin = require("copy-webpack-plugin");

module.exports = {
    webpack: (config, { dev, vendor, copyIgnore }) => {
        // Perform customizations to webpack config
        console.log("Config: ", JSON.stringify(config.module.rules));
        // console.log("Config: ", config.module.rules[1].toString());

        // config.module.noParse = /notCompileScripts\/some-dir/
        // config.module.noParse = /libs/
        config.module.rules.push({
            test: /\.css$/i,
            use: ["style-loader", "css-loader"],
        });
        config.entry = GlobEntriesPlugin.getEntries(
            [
                // resolve('app', '*.js'),
                resolve('app', '?(scripts)/**/*.js'),
                resolve('app', '?(styles/**/*.css)'),
                // resolve('app', '?(libs)/*.js')
            ],
            // {
            //     ignore: 'libs/*.js'
            // }
        )

        // console.log("copyIgnore: ", copyIgnore);
        // console.log("dev: ", dev);
        // console.log("vendor: ", vendor);

        // config.plugins.push(
        //     new CopyPlugin({
        //         patterns: [
        //             { from: "libs", to: "libs", info: { minimized: false } }
        //         ]
        //     })
        // );

        // Important: return the modified config
        // console.log("Config: ", JSON.stringify(config));
        return config
    },
    copyIgnore: ['scripts/*.js', 'scripts/**/*.js', '**/*.json']
}
  • I see you have tried CopyPlugin, it is a good way but you have to set `minimized` to `true` - indicates that the source is already minimized. I failed on the same case. – 5ulo Oct 28 '22 at 17:42

0 Answers0