简体   繁体   English

bundle.js缓慢加载

[英]bundle.js slow loading

bundle.js (2.4 Mb) loading take 40 sec - 1.5 min: bundle.js(2.4 Mb)加载需要40秒 - 1.5分钟: 截图在这里

This is my webpack.config.js : 这是我的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. 您用于webpack的配置似乎是一个开发版本。 Try using a production configuration which usually provides extra optimisations like uglification and extract CSS plugin. 尝试使用生产配置,通常提供额外的优化,如uglification和提取CSS插件。

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. 您还应检查服务器配置以进行进一步的优化,例如gzipping,这会将下载大小减少约5倍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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