Fitbit / webpack-config

Helps to load, extend and merge webpack configs
https://fitbit.github.io/webpack-config
Apache License 2.0
252 stars 18 forks source link

possible issue with uglifyjs-webpack-plugin #106

Closed RahavLussato closed 7 years ago

RahavLussato commented 7 years ago

you can check that here

mdreizin commented 7 years ago

Hello @RahavLussato! Thanks for reporting this issue.

I will take a look on this issue, but for now you can use new webpack.optimize.UglifyJsPlugin(...).

Sorry for inconvenience.

mdreizin commented 7 years ago

@RahavLussato I have read whole conversation, tried some workarounds and I can tell that root issue in uglifyjs-webpack-plugin@1.0.0-beta.2.

Need to merge all configs into single one to exclude webpack-config related issues:

const path = require('path'),
    webpack = require('webpack'),
    UglifyJSPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
    output: {
        path: path.join(__dirname, './dist/bundledCode'),
        filename: "bundle.js?[hash]" ,
        publicPath: '/'
    },
    node: {
        fs: 'empty'
    },
    externals: [
        {
            './cptable': 'var cptable'
        },
        {
            './jszip': 'jszip'
        }
    ],
    devtool: 'source-map',
    entry: {
        js: ['./src/client.jsx']
    },
    plugins: [
        new webpack.IgnorePlugin(/jsdom$/),
        new webpack.optimize.CommonsChunkPlugin({
            name: 'vendor',
            minChunks: Infinity,
            filename: '[name].js?[hash]'
        }),
        new UglifyJSPlugin({
            uglifyOptions: {
                mangle: { properties: {reserved: ['$super', '$', 'exports', 'require'] }},
                ecma: 8,
                compress: { warnings: false },
                output: {
                    comments: false,
                    beautify: false
                }
            },
            parallel: {
                cache: true
            },
            sourceMap: true
        })
    ],
    resolve: {
        descriptionFiles: ["package.json"],
        extensions: ['.json', '.js', '.jsx'],
        modules: [path.resolve(__dirname, "../"), "node_modules"]
    },
    module: {
        loaders: [
            { test: /\.(js|jsx)$/, exclude: /node_modules/, use:"babel-loader?compact=false" }
        ]
    }
};

If we run yarn build with uglifyjs-webpack-plugin@1.0.0-beta.2 we will get unminified version, but if we switch back to uglifyjs-webpack-plugin@0.4.6 (or webpack.optimize.UglifyJsPlugin) the everything will work fine.

mdreizin commented 7 years ago

@RahavLussato Do you mind if I close this issue?

RahavLussato commented 7 years ago

@mdreizin thanks for the help