Prevent modification (minimization and optimization) of a file in webpack

Viewed 52

These are the settings in my webpack.config file:

var result2 = {
    mode: 'development',
    entry: bundles,
    output: {
        filename: '[name].[contenthash].js',
        path: path.resolve(env.outputPath),
        publicPath: '/MyApp/dist/custom'
    },
    devtool: false,//devtool: false
    plugins: [
        ...htmlPlugins1(env)
    ]
}

var htmlPlugins1 = function (env) {
    var htmlFileName = path.join(path.resolve(env.outputPath), '../Views');
    var htmls = [
        { filename: path.join(htmlFileName, '__myfilejs.cshtml'), chunks: ['mychunkjs'] }
    ];

    var htmlPlugins = [];
    for (var i = 0; i < htmls.length; i++) {
            let plugin = new HtmlWebpackPlugin({
                inject: 'head',
                hash: true,
                chunksSortMode: 'manual',
                filename: htmls[i].filename,
                chunks: htmls[i].chunks
            });

            htmlPlugins = [...htmlPlugins, plugin];
    }

    return htmlPlugins;
}

What I want to do is for one of the .js file in the application to not be modified at all, just be renamed with a hash in its name. I set optimization.minimize to false, devtool to false, but the file still gets modified. The hashing works, but I want to prevent the optimization, I need the file as it is. What should I try?

0 Answers
Related