简体   繁体   中英

bundle.js slow loading

bundle.js (2.4 Mb) loading take 40 sec - 1.5 min: 截图在这里

This is my webpack.config.js :

const webpack = require('webpack');
const config = {
 entry: {
        "App":__dirname + '/js/App.jsx'
},
output: {
    path: __dirname + '/dist',
    filename: 'bundle.js',
},
resolve: {
    extensions: ['.js', '.jsx', '.css']
},
module: {
  rules: [
    {
      test: /\.jsx?/,
      exclude: /node_modules/,
      use: 'babel-loader',
      loader: 'babel-loader?cashezdirectory'
    },
   // { test: /\.css$/, loader: 'style-loader!css-loader' }
  ]
},
externals: {
react: 'React',
jquery: 'jQuery'}
};
module.exports = config;

Is the any way to make loading faster?

The configuration that you are using for webpack seems to be a development version. Try using a production configuration which usually provides extra optimisations like uglification and extract CSS plugin.

plugins: [
    new ExtractTextPlugin('styles.css'),
    new webpack.optimize.UglifyJsPlugin({
        sourceMap: true
    })
],

This should reduce the bundle size considerably(at least half).

You should also check your server configuration for further optimisations like gzipping which will reduce the download size by ~5 times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM