单文件模式

// 新建 webpack.production.config.js
// in package.json
"deploy":"NODE_EVN=production webpack -p -config webpack.production.config.js"
// in web.production.config.js
// 和开发环境不同之处在于入口和出口. 相应的在 HTML 和 JS 源也要进行修改

var path = require('path')
var node_modules_dir = path.resolve(__dirname, 'node_modules')

module.exports = {
  entry:[
    'babel-polyfill',
    path.resolve(__dirname, 'app/main.js')
  ],
  output:{
    path: path.resolve(__dirname, 'build'),
    filename: 'app.js'
  },
  module:{
    loaders:[
      {
        ...
      }
    ]
  }
}
`</pre>

### 多文件模式

库最好不要打包, 因为一般库都不会改动, 所以 load 一次就够了.

对库进行分离

<pre>`// in webpack.production.config.js
var path = require('path')
var webpack = require('webpack')
var node_modules_dir = path.resolve(__dirname, 'node_modules')

module.exports = {
  entry:{
    app: [path.resolve(__dirname, 'app/main.js')],
    react: ['babel-polyfill','react','react-dom']
  },
  output:{
    path: path.resolve(__dirname, 'build'),
    filename: 'app.js'
  },
  module:{
    loaders:[
      ...
    ]
  },
  plugins:[
    new webpack.optimize.CommonsChunkPlugin('react','react.js')
  ]
}