Saturday, March 17, 2018

Laravel Mix Custom Produce Big JS File - development

Laravel Mix Custom Produce Big JS File

I’m having trouble caused by the big size file of bundle that is created via webpack

It produce the bundle around 1.38mb which slowing down the web on the first load

I’m using laravel mix webpack for react preset

I have already try to give some plugin on the webpack to reduce the size but it seems doesn’t work at all

Before giving the plugin it produce 1.38mb file, after giving the plugin it still 1.38mb file

here are the plugins i’m using

new webpack.DefinePlugin({ // <-- key to reducing React's size
            'process.env': {
            'NODE_ENV': JSON.stringify('production')
        }
    }),
    new webpack.optimize.DedupePlugin(), //dedupe similar code 
    new webpack.optimize.UglifyJsPlugin({
        output: {
            comments: false
        },
        mangle: true,
        sourcemap: false,
        debug: false,
        minimize: true,
        compress: {
            warnings: false,
            screw_ie8: true,
            conditionals: true,
            unused: true,
            comparisons: true,
            sequences: true,
            dead_code: true,
            evaluate: true,
            if_return: true,
            join_vars: true
        }
    }),
    new webpack.optimize.AggressiveMergingPlugin()//Merge chunks 

anyone has suggestion for my problem here?



from Laravel Questions and Answers https://laravelquestions.com/laravel/laravel-mix-custom-produce-big-js-file/
via Lzo Media

No comments:

Post a Comment