Webpack2 BIG捆绑文件

时间:2017-01-05 09:31:54

标签: webpack webpack-2

bundle.js  2.81 MB       0  [emitted]  [big]  main
  [13] ./~/react-dom/lib/ReactDOMComponentTree.js 6.16 kB {0} [built]
  [15] ./~/fbjs/lib/ExecutionEnvironment.js 1.06 kB {0} [built]
  [64] ./~/react/lib/React.js 2.69 kB {0} [built]
  [90] ./~/react/react.js 56 bytes {0} [built]
 [194] ./src/client/app/containers/Index/index.jsx 2.07 kB {0} [built]
 [195] ./~/react-dom/index.js 59 bytes {0} [built]
 [197] ./~/babel-polyfill/lib/index.js 833 bytes {0} [built]
 [406] ./~/react-dom/lib/ReactDOM.js 5.14 kB {0} [built]
 [438] ./~/react-dom/lib/ReactVersion.js 350 bytes {0} [built]
 [455] ./~/react-dom/lib/findDOMNode.js 2.46 kB {0} [built]
 [463] ./~/react-dom/lib/renderSubtreeIntoContainer.js 422 bytes {0} [built]
 [466] ./~/react/lib/ReactChildren.js 6.19 kB {0} [built]
 [467] ./~/react/lib/ReactClass.js 26.5 kB {0} [built]
 [468] ./~/react/lib/ReactDOMFactories.js 5.53 kB {0} [built]
 [476] ./src/client/app/private.jsx 210 bytes {0} [built]
    + 462 hidden modules

这太大了。这是我的配置。

.babelrc:

{
  "presets": [
    [
      "es2015",
      {
        "modules": false
      }
    ],
    "es2016",
    "react"
  ],
  "plugins": [
    "transform-react-jsx",
    "transform-regenerator"
  ]
}

webpack.config.js:

'use strict';

const path = require('path');

module.exports = [
  {
    devtool: 'inline-source-map',
    entry: './src/client/app/private.jsx',
    output: {
      path: path.resolve(__dirname, 'src/client/private'),
      filename: 'bundle.js'
    },
    resolve: {
      extensions: ['.js', '.jsx']
    },
    module: {
      rules: [
        {
          test: /\.jsx$/,
          use: [
            {
              loader: 'babel-loader'
            },
          ],
          exclude: /node_modules/
        }
      ]
    }
  }
];

现在,我查看了该文件,其中很多都是评论,所以我认为它将它捆绑到开发包中。

我已将源地图设置为内联,如何测试生产包?

1 个答案:

答案 0 :(得分:0)

对于制作,您可能需要既未包含也未引用的源地图,因此请使用hidden-source-map

如果您正在捕获并报告来自客户端的运行时异常,您现在可以使用其他工具,并提供相应的源映射来调试错误。