Git Product home page Git Product logo

webpack-parallel-uglify-plugin's Introduction

webpack-parallel-uglify-plugin Build status Coverage Status

This plugin serves to help projects with many entry points speed up their builds. The UglifyJS plugin provided with webpack runs sequentially on each of the output files. This plugin runs uglify in parallel with one thread for each of your available cpus. This can lead to significantly reduced build times as minification is very CPU intensive.

Config

Configuring is straightforward.

import ParallelUglifyPlugin from 'webpack-parallel-uglify-plugin';

module.exports = {
  plugins: [
    new ParallelUglifyPlugin({
      // Optional regex, or array of regex to match file against. Only matching files get minified.
      // Defaults to /.js$/, any file ending in .js.
      test,
      include, // Optional regex, or array of regex to include in minification. Only matching files get minified.
      exclude, // Optional regex, or array of regex to exclude from minification. Matching files are not minified.
      cacheDir, // Optional absolute path to use as a cache. If not provided, caching will not be used.
      workerCount, // Optional int. Number of workers to run uglify. Defaults to num of cpus - 1 or asset count (whichever is smaller)
      sourceMap, // Optional Boolean. This slows down the compilation. Defaults to false.
      uglifyJS: {
        // These pass straight through to uglify-js@3.
        // Cannot be used with terser.
        // Defaults to {} if not neither uglifyJS or terser are provided.
        // You should use this option if you need to ensure es5 support. uglify-js will produce an
        // error message if it comes across any es6 code that it can't parse.
      },
      terser: {
        // These pass straight through to terser.
        // Cannot be used with uglifyJS.
        // terser is a fork of uglify-es, a version of uglify that supports ES6+ version of uglify
        // that understands newer es6 syntax. You should use this option if the files that you're
        // minifying do not need to run in older browsers/versions of node.
      }
    }),
  ],
};

Example Timings

These times were found by running webpack on a very large build, producing 493 output files and totaling 144.24 MiB before minifying. All times are listed with fully cached babel-loader for consistency.

Note: I no longer have access to the huge project that I was testing this on.

No minification: Webpack build complete in: 86890ms (1m 26s)
Built in uglify plugin: Webpack build complete in: 2543548ms (42m 23s)
With parallel plugin: Webpack build complete in: 208671ms (3m 28s)
With parallel/cache: Webpack build complete in: 98524ms (1m 38s)

webpack-parallel-uglify-plugin's People

Contributors

dicksmith avatar elektronik2k5 avatar etripier avatar gdborton avatar goodforonefare avatar jaxgeller avatar lencioni avatar sajmoon avatar tonkpils avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

webpack-parallel-uglify-plugin's Issues

sourcemaps aren't generated when minifying

without minifying the build, webpack generates sourcemaps correctly.

upon minifying the build with your plugin:

exports.minify = function (path) {
    return {
        plugins: [
            new ParallelUglifyPlugin({
                cacheDir: path + '/cache/'
            })
        ]
    };
};
config = merge(
            config,
            {
                devtool: 'source-map',
                output: {
                    path: PATHS.build,
                    filename: '[name].js',
                    sourceMapFilename: '[name].js.map'
                },
            },
            parts.setupLess([PATHS.app]),
            parts.setFreeVariable(
                'process.env.NODE_ENV',
                'production'
            ),
            parts.minify(PATHS.build)
        );
  1. webpack doesn't output a sourceMap file
  2. the //# sourceMappingUrl=app.js.map is missing from file output

we'd really love to use your parallelized version, but without being able to generate sourcemaps in production, we cannot! :(

React dead code elimination error in production

there is problem when I use webpack-parallel-uglify-plugin, but it's OK using uglifyjs-webpack-plugin. I'm not sure it is caused by this plugin.
the problem show as below:
Uncaught Error: React is running in production mode, but dead code elimination has not been applied. Read how to correctly configure React for production: https://fb.me/react-perf-use-the-production-build at <anonymous>:21:35

Sourcemaps are missing

In my webpack config I have enabled sourcemaps by devtool: 'source-map', but they don't show in generated files.

TypeError: S.input is not a function

Wanted to give this a try, but ran into some errors:

TypeError: S.input is not a function
    at next (eval at <anonymous> (/Users/ebenoist/dev/reverb/node_modules/webpack-parallel-uglify-plugin/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2078:25)
    at Object.parse (eval at <anonymous> (/Users/ebenoist/dev/reverb/node_modules/webpack-parallel-uglify-plugin/node_modules/uglify-js/tools/node.js:28:1), <anonymous>:2064:15)
    at addFile (/Users/ebenoist/dev/reverb/node_modules/webpack-parallel-uglify-plugin/node_modules/uglify-js/tools/node.js:70:33)
    at /Users/ebenoist/dev/reverb/node_modules/webpack-parallel-uglify-plugin/node_modules/uglify-js/tools/node.js:82:21
    at Array.forEach (native)
    at Object.exports.minify (/Users/ebenoist/dev/reverb/node_modules/webpack-parallel-uglify-plugin/node_modules/uglify-js/tools/node.js:77:26)
    at minify (/Users/ebenoist/dev/reverb/node_modules/webpack-parallel-uglify-plugin/lib/worker.js:5:17)
    at process.messageHandler (/Users/ebenoist/dev/reverb/node_modules/webpack-parallel-uglify-plugin/lib/worker.js:11:24)
    at emitTwo (events.js:106:13)
    at process.emit (events.js:191:7)
undefined:2078
            S.token = S.input();
                        ^

Let me know if I can help debug!

Possible hang up problem

Thanks for the great work, It really speed up my static assets building process. However, it's strange that it could cause the system hang up in some rare cases.
I still can't find any clue, It's hard to recurrence the case, I'm sorry.
Did anyone meet the same issue?

I can't minify my css .

I use [email protected] in my project. When I want to use ExtractTextPlugin to separate my css from js.

my options:
new ParallelUglifyPlugin({
test: [/.js$/, /.css$/],
cacheDir: '.cache/',
workerCount: 4,
uglifyJS: {
output: {
comments: false
},
compress: {
warnings: false
}
}

I get error as fllow:
ERROR in minifying main.css
SyntaxError: Unexpected token: punc ({)

echarts error:main.js:1 Uncaught Error: axisPointer CartesianAxisPointer exists

When I use webpack-parallel-uglify-plugin and echarts,I got a error:

main.js:1 Uncaught Error: axisPointer CartesianAxisPointer exists
at Function.a.registerAxisPointerClass (vendor.js:1)
at Object.install (vendor.js:1)
at t (vendor.js:1)
at Object.install (vendor.js:1)
at t (vendor.js:1)
at Module../node_modules/echarts/index.js (vendor.js:1)
at w (main.js:1)
at e (main.js:1)
at Module../src/index.ts (main.js:1)
at w (main.js:1)

After comparison and investigation,I found webpack-parallel-uglify-plugin cause the error.

versions:
"echarts": "^5.2.2",
"webpack-parallel-uglify-plugin": "^2.0.0",

webpack.config.js:
const HtmlWebpackPlugin = require('html-webpack-plugin');
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const path = require('path');
const HappyPack = require('happypack');
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');

module.exports = {
entry: path.resolve(__dirname, 'src', 'index.ts'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
chunkFilename: '[name].[hash:4].js',
},
resolve: {
extensions: ['.ts', '.js'],
},
optimization: {
// 1. 这个配置必须
minimize: false,
splitChunks: {
cacheGroups: {
default: {
name: 'common',
chunks: 'initial',
minChunks: 2,
priority: -20,
},
vendors: {
test: /[\/]node_modules[\/]/,
name: 'vendor',
chunks: 'initial',
priority: -10,
},
},
},
},
devtool: 'cheap-source-map',
module: {
rules: [
{
test: /.css$/,
use: ['happypack/loader?id=css'],
// use: ['style-loader', 'css-loader'],
},
{
test: /.(ts|js)$/,
use: ['happypack/loader?id=babel'],
// loader: 'babel-loader',
exclude: [path.join(__dirname, 'node_modules')],
// options: {
// presets: ['@babel/preset-env', '@babel/typescript'],
// },
},
],
},
devServer: {
port: 'auto',
client: {
reconnect: 5,
progress: true,
},
hot: true,
static: path.resolve(__dirname, 'dist/index.html'),
},
plugins: [
new BundleAnalyzerPlugin(),
new ParallelUglifyPlugin({
uglifyJS: {
// output: {
// beautify: false,
// comments: false,
// },
// warnings: false,
// compress: {
// drop_console: true,
// collapse_vars: true,
// reduce_vars: true,
// },
},
}),
new HappyPack({
id: 'babel',
use: [
{
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env', '@babel/typescript'],
},
},
],
}),
new HappyPack({
id: 'css',
loaders: ['style-loader', 'css-loader'],
}),
new HtmlWebpackPlugin({
title: 'TypeScript Learner',
filename: path.resolve(__dirname, 'dist', 'index.html'),
template: path.resolve(__dirname, 'public', 'index.html'),
}),
],
};

source map not working

I have used webpack-parallel-uglify-plugin. It does generate *.js.map, and the source files also contains comments like "sourceMappingURL=a-614d71f532b520f2be01.js.map". But when I open the page in browsers, it was empty. Here are my config file and the picture in browser.
webpack: 3.11.0
webpack-parallel-uglify-plugin: 1.1.0

devtool='source-map';
plugins.push(
    new ParallelUglifyPlugin({
       sourceMap: true,
       uglifyJS: {
          mangle: {},
          compress: {
            warnings: false,
            properties: false,
          },
          output: { comments: false },
        },
    })
);

issue

If I use webpack.optimize.UglifyJsPlugin, every thing works fine.

 plugins.push(new webpack.optimize.UglifyJsPlugin({
          sourceMap: true,
          mangle: {},
          compress: {
            warnings: false,
            properties: false,
          },
          output: {},
          comments: false,
        }));

Could you please tell me what's wrong with my config file? Thank you so much!

workers.setMaxListeners exceeds hardcoded value

In our project, we get this warning:

(node:19903) Warning: Possible EventEmitter memory leak detected. 101 message listeners added. Use emitter.setMaxListeners() to increase limit

It appears in uglifier.js, the worker is hardcoded to 100 max listeners:
worker.setMaxListeners(100);

I will open a pull request to make that number a config option.

webpack-parallel-uglify-plugin cannot uglify any file

when i use new webpack.optimize.UglifyJsPlugin, the file is uglified as normal. but when i change to the webpack-parallel-uglify-plugin with the same uglify config. the result is that the is no file uglified.

my webpack.config.js as below, you can see the target config at the bottom

/* eslint-env node */
/* eslint-disable import/no-commonjs */
require("babel-register");
require("babel-polyfill");

var webpack = require('webpack');
var path = require('path');
var webpackPostcssTools = require('webpack-postcss-tools');

var ExtractTextPlugin = require('extract-text-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var HtmlWebpackHarddiskPlugin = require('html-webpack-harddisk-plugin');
var UnusedFilesWebpackPlugin = require("unused-files-webpack-plugin").default;
var BannerWebpackPlugin = require('banner-webpack-plugin');
var AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin');
var HappyPack = require('happypack');
var ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');

var _ = require('underscore');
var glob = require('glob');
var fs = require('fs');

var chevrotain = require("chevrotain");
var allTokens = require("./frontend/src/metabase/lib/expressions/tokens").allTokens;

function hasArg(arg) {
    var regex = new RegExp("^" + ((arg.length === 2) ? ("-\\w*"+arg[1]+"\\w*") : (arg)) + "$");
    return process.argv.filter(regex.test.bind(regex)).length > 0;
}

var SRC_PATH = __dirname + '/frontend/src/metabase';
var BUILD_PATH = __dirname + '/resources/frontend_client';

// default NODE_ENV to development
var NODE_ENV = process.env["NODE_ENV"] || "development";

// Need to scan the CSS files for variable and custom media used across files
// NOTE: this requires "webpack -w" (watch mode) to be restarted when variables change :(
var IS_WATCHING = hasArg("-w") || hasArg("--watch");
if (IS_WATCHING) {
    process.stderr.write("Warning: in webpack watch mode you must restart webpack if you change any CSS variables or custom media queries\n");
}

// Babel:
var BABEL_CONFIG = {
    cacheDirectory: ".babel_cache"
};

// Build mapping of CSS variables
var CSS_SRC = glob.sync(SRC_PATH + '/css/**/*.css');
var CSS_MAPS = { vars: {}, media: {}, selector: {} };
CSS_SRC.map(webpackPostcssTools.makeVarMap).forEach(function(map) {
    for (var name in CSS_MAPS) _.extend(CSS_MAPS[name], map[name]);
});

// CSS Next:
var CSSNEXT_CONFIG = {
    features: {
        // pass in the variables and custom media we scanned for before
        customProperties: { variables: CSS_MAPS.vars },
        customMedia: { extensions: CSS_MAPS.media }
    },
    import: {
        path: ['resources/frontend_client/app/css']
    },
    compress: false
};

var CSS_CONFIG = {
    localIdentName: NODE_ENV !== "production" ?
        "[name]__[local]___[hash:base64:5]" :
        "[hash:base64:5]",
    restructuring: false,
    compatibility: true,
    url: false, // disabled because we need to use relative url()
    importLoaders: 1
}

// happypack.config
var happyPackConfig = {
    plugins:[
        new HappyPack({
           id: 'happyBabel',
           threads: 4,
           cache: true,
           loaders:[
               {
                   path: 'babel',
                   query: BABEL_CONFIG
               }
           ]
        }),
        new HappyPack({
            id: 'happyEslint',
            threads: 4,
            cache: true,
            loaders: ['eslint']
        })
    ]
}

var config = module.exports = {
    context: SRC_PATH,

    // output a bundle for the app JS and a bundle for styles
    // eventually we should have multiple (single file) entry points for various pieces of the app to enable code splitting
    entry: {
        "app-main": './app-main.js',
        "app-public": './app-public.js',
        "app-embed": './app-embed.js',
        styles: './css/index.css',
    },

    // output to "dist"
    output: {
        path: BUILD_PATH + '/app/dist',
        // NOTE: the filename on disk won't include "?[chunkhash]" but the URL in index.html generated by HtmlWebpackPlugin will:
        filename: '[name].bundle.js?[hash]',
        publicPath: 'app/dist/'
    },

    module: {
        loaders: [
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules/,
                // loader: "babel",
                // query: BABEL_CONFIG
                loader: `${path.resolve(__dirname, './node_modules', 'happypack/loader')}?id=happyBabel`
            },
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules|\.spec\.js/,
                // loader: 'eslint'
                loader: `${path.resolve(__dirname, './node_modules', 'happypack/loader')}?id=happyEslint`
            },
            {
                test: /\.(eot|woff2?|ttf|svg|png)$/,
                loader: "file-loader"
            },
            {
                test: /\.json$/,
                loader: "json-loader"
            },
            {
                test: /\.css$/,
                loader: ExtractTextPlugin.extract("style-loader", "css-loader?" + JSON.stringify(CSS_CONFIG) + "!postcss-loader")
            }
        ]
    },

    resolve: {
        extensions: ["", ".webpack.js", ".web.js", ".js", ".jsx", ".css"],
        alias: {
            'metabase':             SRC_PATH,
            'style':                SRC_PATH + '/css/core/index.css',
            'ace':                  __dirname + '/node_modules/ace-builds/src-min-noconflict',
            'resource':             __dirname + '/resources'
        }
    },

    plugins: [
        new UnusedFilesWebpackPlugin({
            globOptions: {
                ignore: [
                    "**/types/*.js",
                    "**/*.spec.*",
                    "**/__support__/*.js"
                ]
            }
        }),
        new webpack.DllReferencePlugin({
            context: __dirname,
            manifest: require('./manifest.json'),
            name:"vendors_dll"
        }),
        // Extracts initial CSS into a standard stylesheet that can be loaded in parallel with JavaScript
        // NOTE: the filename on disk won't include "?[chunkhash]" but the URL in index.html generated by HtmlWebpackPlugin will:
        new ExtractTextPlugin('[name].bundle.css?[contenthash]'),
        new HtmlWebpackPlugin({
            filename: '../../index.html',
            chunks: ["app-main", "styles"],
            template: __dirname + '/resources/frontend_client/index_template.html',
            inject: 'head',
            alwaysWriteToDisk: true,
        }),
        new HtmlWebpackPlugin({
            filename: '../../public.html',
            chunks: ["app-public", "styles"],
            template: __dirname + '/resources/frontend_client/index_template.html',
            inject: 'head',
            alwaysWriteToDisk: true,
        }),
        new HtmlWebpackPlugin({
            filename: '../../embed.html',
            chunks: ["app-embed", "styles"],
            template: __dirname + '/resources/frontend_client/index_template.html',
            inject: 'head',
            alwaysWriteToDisk: true,
        }),
        new AddAssetHtmlPlugin({
            filepath: BUILD_PATH + '/app/dist/*.dll.js',
            includeSourcemap: false
        }),
        new HtmlWebpackHarddiskPlugin({
            outputPath: __dirname + '/resources/frontend_client/app/dist'
        }),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify(NODE_ENV)
            }
        }),
        new BannerWebpackPlugin({
            chunks: {
                'app-main': {
                    beforeContent: "/*\n* This file is subject to the terms and conditions defined in\n * file 'LICENSE.txt', which is part of this source code package.\n */\n",
                },
                'app-public': {
                    beforeContent: "/*\n* This file is subject to the terms and conditions defined in\n * file 'LICENSE.txt', which is part of this source code package.\n */\n",
                },
                'app-embed': {
                    beforeContent: "/*\n* This file is subject to the terms and conditions defined in\n * file 'LICENSE-EMBEDDING.txt', which is part of this source code package.\n */\n",
                },
            }
        }),
    ].concat(happyPackConfig.plugins),

    postcss: function (webpack) {
        return [
            require("postcss-import")(),
            require("postcss-url")(),
            require("postcss-cssnext")(CSSNEXT_CONFIG)
        ]
    }
};

if (NODE_ENV === "hot") {
    // suffixing with ".hot" allows us to run both `yarn run build-hot` and `yarn run test` or `yarn run test-watch` simultaneously
    config.output.filename = "[name].hot.bundle.js?[hash]";

    // point the publicPath (inlined in index.html by HtmlWebpackPlugin) to the hot-reloading server
    config.output.publicPath = "http://localhost:8080/" + config.output.publicPath;

    config.module.loaders.unshift({
        test: /\.jsx$/,
        exclude: /node_modules/,
        loaders: ['react-hot', 'babel?'+JSON.stringify(BABEL_CONFIG)]
    });

    // disable ExtractTextPlugin
    config.module.loaders[config.module.loaders.length - 1].loader = "style-loader!css-loader?" + JSON.stringify(CSS_CONFIG) + "!postcss-loader"

    config.devServer = {
        hot: true,
        inline: true,
        contentBase: "frontend"
        // if webpack doesn't reload UI after code change in development
        // watchOptions: {
        //     aggregateTimeout: 300,
        //     poll: 1000
        // }
        // if you want to reduce stats noise
        // stats: 'minimal' // values: none, errors-only, minimal, normal, verbose
    };

    config.plugins.unshift(
        new webpack.NoErrorsPlugin(),
        new webpack.HotModuleReplacementPlugin()
    );
}

if (NODE_ENV !== "production") {
    // replace minified files with un-minified versions
    for (var name in config.resolve.alias) {
        var minified = config.resolve.alias[name];
        var unminified = minified.replace(/[.-\/]min\b/g, '');
        if (minified !== unminified && fs.existsSync(unminified)) {
            config.resolve.alias[name] = unminified;
        }
    }

    // enable "cheap" source maps in hot or watch mode since re-build speed overhead is < 1 second
    config.devtool = "cheap-module-source-map";

    // works with breakpoints
    // config.devtool = "inline-source-map"

    // helps with source maps
    config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]';
    config.output.pathinfo = true;
} else {
    // config.plugins.push(new webpack.optimize.UglifyJsPlugin({
    //     // suppress uglify warnings in production
    //     // output from these warnings was causing Heroku builds to fail (#5410)
    //     compress: {
    //         warnings: false,
    //     },
    //     output: {
    //         comments: false,
    //     },
    //     mangle: {
    //         // this is required to ensure we don't minify Chevrotain token identifiers
    //         // https://github.com/SAP/chevrotain/tree/master/examples/parser/minification
    //         except: allTokens.map(function(currTok) {
    //             return chevrotain.tokenName(currTok);
    //         })
    //     }
    // }))
    
    config.plugins.push(new ParallelUglifyPlugin({
        cacheDir: '.js_cache/',
        uglifyJS:{
            output: {
                comments: false,
            },
            compress: {
                warnings: false,
            },
            mangle: {
                // this is required to ensure we don't minify Chevrotain token identifiers
                // https://github.com/SAP/chevrotain/tree/master/examples/parser/minification
                except: allTokens.map(function(currTok) {
                    return chevrotain.tokenName(currTok);
                })
            }
        }
    }))

    config.devtool = "source-map";
}

Remove tmp files that created by uglifier

hi @gdborton :
webpack-parallel-uglify-plugin is a very useful and greateful plugin, it save a lot of my time.
but recently, I found some problem.

I use webpack-parallel-uglify-plugin in MacOs, Linux and Win 10.
None of these platforms deletes tmp files. In win 10, they generate in C:/user/username/AppData/Local/Temp, with many othes apps' tmp data.

In MacOs, they generate in /var/ + random string.

None of them were deleted after compress. So the folder to save the tmp files biger and biger.

I think is it possible to remove the afer we read them ?

Also, I think the tmp package of node doesn't work to delete the tmp files through setGracefulCleanup API.

DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead

Hi,

I got the following warning message when building my project:

DeprecationWarning: Tapable.plugin is deprecated. Use new API on `.hooks` instead

After checking out webpack dependencies (webpack, loaders, plugins, …), i found out that webpack-parallel-uglify-plugin uses compiler.plugin('xxx').

Now that webpack 4 is using a new plugin system and deprecates the previous APIs, should we update webpack-parallel-uglify-plugin? If yes, i am willing to send a PR.

uglify-js 3.9.3 Build vendor package large

The latest npm install found that the uglify-js version used by webpack-parallel-uglify-plugin is 3.9.3. This version will cause the packaged files of node_modules to become very large, from the original 1.8M to 4.52M. But changing uglify-js to version 3.9.1 can be packaged normally, please solve this problem, or specify uglify-js version to 3.9.1 to make it work properly

image

image

Problem with file-loader

I have a JS file with the following code:

   import 'file-loader!./foo.js';

This gives the following error:

    ERROR in minifying d41d8cd98f00b204e9800998ecf8427e.js
    S.input is not a function

where d41d8cd98f00b204e9800998ecf8427e.js corresponds to foo.js.

Is there a way to work around this problem (except excluding based on filename, since I can't predict the filename).

Cannot call a class as a function

when i use webpack-parallel-uglify-plugin instead of UglifyJsPlugin,ti raise up an error,but use UglifyJsPlugin the project is running success,the error is :07.js:formatted:5238 Uncaught TypeError: Cannot call a class as a function,my config is simple,pluginArr.push(new ParallelUglifyPlugin({
cacheDir: '.cache/',
uglifyJS:{
compress: {
warnings: true,
}
}
})
);

Merge with the official contrib plugin?

great work on this plugin. Have you given any thought to merging with the official webpack-contrib uglify plugin?

That way, every Webpack user can receive this massive speedup without having to find this plugin! Also, it doesn't always make sense to parallelize, so by moving into the official plugin, we can intelligently choose whether to parallelize or not, and give users an option to parallelize or not.

Thoughts?

can't uglify @antv/g6

Hi bro,
I have used this plugin successful to build until my porject quote @antv/g6. I don't know how to fix it. can you help me?

"size" argument must not be larger than 2147483647

My Code:

// https://github.com/gdborton/webpack-parallel-uglify-plugin
const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin');
const parallelUglifyPlugin = new ParallelUglifyPlugin({
  // include: /.*\/src\/.*/,
  exclude: /node\/\_modules\/.*/,
  cacheDir: path.resolve(__dirname, './cache'),
  uglifyJS: {
    compress: {
      warnings: false,
      // Disabled because of an issue with Uglify breaking seemingly valid code:
      // https://github.com/facebookincubator/create-react-app/issues/2376
      // Pending further investigation:
      // https://github.com/mishoo/UglifyJS2/issues/2011
      comparisons: false,
    },
    mangle: {
      safari10: true,
    },
    output: {
      comments: false,
      // Turned on because emoji and regex is not minified properly using default
      // https://github.com/facebookincubator/create-react-app/issues/2488
      ascii_only: true,
    }
  }
})

The others webpack plugins that i used for my MPA(Multiple Page Application):

const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const ManifestPlugin = require('webpack-manifest-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const eslintFormatter = require('react-dev-utils/eslintFormatter');

The first Error is this:

"size" argument must not be larger than 2147483647

maybe it is useful for it but i am confusing for that javascript-read-large-files-failed)

The second error like following:

`safari10` is not a supported option?

Then i annotate this line and It works.

  • Why?
  • Anything wrong?
  • Is it a bug?
  • What happened?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.