webpack 每次修改都要扫描 node_modules

每次修改东西,都会重新扫描 react/lib
这些库已经使用 CommonsChunkPlugin 抽离出来了

const path = require('path');
const webpack = require('webpack');
const config = require('../config/config');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: {
      app: [
      config.utils_paths.client('index.js'),
       'webpack-hot-middleware/client?path=/__webpack_hmr&timeout=20000'
      ],
      vendor: ["react","react-dom"]
  },
  devtool: "source-map",
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, config.utils_paths.dist()),
    publicPath: '/'
  },
  devServer: {
    hot: true,
    contentBase: path.resolve(__dirname, config.utils_paths.dist()),
    publicPath: '/'
  },
  module: {
      loaders: [{
      test: /\.(js|jsx)$/,
      exclude: /node_modules/,
      loader: 'babel-loader'
    }]
  },
  plugins: [
      new webpack.optimize.CommonsChunkPlugin({name:['vendor','manifest']}),
      new HtmlWebpackPlugin({
        template: config.utils_paths.client('index.html'),
        hash: false,
        filename: 'index.html',
        inject: 'body',
        minify: {
          collapseWhitespace: true
        }
      }),
      new webpack.HotModuleReplacementPlugin()
  ]
};

图片描述

阅读 2.9k
1 个回答
推荐问题
宣传栏