Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 寻找更多的网页包生产捆绑优化_Javascript_Webpack - Fatal编程技术网

Javascript 寻找更多的网页包生产捆绑优化

Javascript 寻找更多的网页包生产捆绑优化,javascript,webpack,Javascript,Webpack,我正试图减少我的应用程序JS包的输出大小,看看这些插件,到目前为止,它们可以帮助我完成这项任务: config.plugins = [ new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('production') } }), new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-

我正试图减少我的应用程序JS包的输出大小,看看这些插件,到目前为止,它们可以帮助我完成这项任务:

config.plugins = [
 new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': JSON.stringify('production')
      }
    }),
  new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en-gb/),
  new ExtractTextPlugin({ filename: "bundle.css" }),
  new webpack.LoaderOptionsPlugin({
    minimize: true,
    debug: false
  }),
  new webpack.optimize.UglifyJsPlugin({
    compress: {
      warnings: false,
      pure_getters: true,
      unsafe: true,
      unsafe_comps: true,
      screw_ie8: true,
    },
    output: {
      comments: false,
      screw_ie8: true,
    },
    mangle: {
      screw_ie8: true,
    },
    sourceMap: false,
    minimize: true
  }),
  new LodashModuleReplacementPlugin({ 'collections': true }),
  new DuplicatePackageCheckerPlugin()
];
对于生产,我还将
devtool
设置为未定义

这是我的
.babelrc
,我也在做一些优化:

{
  "presets": [
    ["es2015", { "es2015": { "loose": true, "modules": false}}],
    "react",
    "stage-0",
  ],  
  "env": {
    "development": {
      "presets": ["react"]
    },
    "production": {
      "plugins": [
        ["transform-react-remove-prop-types", {
          "mode": "wrap",
        }]
      ]
    }
  },
  "plugins": ["lodash"]
}

还有什么我能做的吗?捆绑包已经减少了很多,但仍然相当大。

查看代码拆分。这不是相同的,而是拆分成更多的块吗?要详细查看@TravMatth。谢谢,关键是让用户只下载他们需要的块,然后缓存其余的