webpack.dev.babel.js 2.39 KB
Newer Older
dengxiaofeng's avatar
dengxiaofeng committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/**
 * DEVELOPMENT WEBPACK CONFIGURATION
 */

const path = require('path');
const CircularDependencyPlugin = require('circular-dependency-plugin');
module.exports = require('./webpack.base.babel')({
  mode: 'development',

  // Add hot reloading in development
  entry: [
    'webpack-hot-middleware/client?reload=true',
    path.join(process.cwd(), 'src/app.js'), // Start with js/app.js
  ],
  optimization: {
邓晓峰's avatar
邓晓峰 committed
16 17 18
    // namedModules: true,
    // namedChunks: true,
    chunkIds: "named",
19
    runtimeChunk: {
20
      name: 'runtime',
21
    },
dengxiaofeng's avatar
dengxiaofeng committed
22
    splitChunks: {
23
      name: false,
24 25 26
      // eslint-disable-next-line no-irregular-whitespace
      chunks: 'all', // all(全部), async(异步的模块),initial(同步的模块)
      // eslint-disable-next-line no-irregular-whitespace
27
      minSize: 20000, // 表示文件大于1k的时候才对它进行打包
28
      // eslint-disable-next-line no-irregular-whitespace
29
      minChunks: 2, // 当某个模块满足minChunks引用次数时,才会被打包。
30
      // eslint-disable-next-line no-irregular-whitespace
31 32
      maxAsyncRequests: 5, // 在打包某个模块的时候,最多分成5个chunk,多余的会合到最后一个chunk中
      maxInitialRequests: Infinity,
33
      automaticNameDelimiter: '~', // 当vendors或者default中的filename不填时,打包出来的文件名就会带~
34 35 36
      cacheGroups: {
        default: false,
        vendors: {
37
          // eslint-disable-next-line no-irregular-whitespace
38
          // 将从node_modules中引入的模块统一打包到common.js文件中
39 40
          name: 'common',
          chunks: 'all',
41 42 43
          minChunks: 2,
          test: /[\\/]node_modules[\\/]/,
        },
邓晓峰's avatar
邓晓峰 committed
44 45 46 47 48 49 50 51 52
        // styles: {
        //   // css统一打包到common.css文件中
        //   name: 'common',
        //   chunks: 'all',
        //   minChunks: 2,
        //   test: /\.(css|less|scss|stylus)$/,
        //   enforce: true,
        //   priority: 50,
        // },
53
      },
dengxiaofeng's avatar
dengxiaofeng committed
54 55 56
    },
  },
  plugins: [
邓晓峰's avatar
邓晓峰 committed
57 58 59 60 61 62 63
    // new CircularDependencyPlugin({
    //   exclude: /node_modules/,
    //   include: /src/,
    //   failOnError: false,
    //   allowAsyncCycles: false,
    //   cwd: process.cwd(),
    // }),
dengxiaofeng's avatar
dengxiaofeng committed
64 65 66 67 68 69 70 71 72
  ],
  devtool: 'cheap-module-source-map',
  node: {
    setImmediate: false,
    process: 'mock',
    dgram: 'empty',
    fs: 'empty',
    net: 'empty',
    tls: 'empty',
邓晓峰's avatar
邓晓峰 committed
73
    child_process: 'empty',
dengxiaofeng's avatar
dengxiaofeng committed
74 75 76 77 78
  },
  performance: {
    hints: false,
  },
});