webpack.config.js 1.47 KB
var debug = process.env.NODE_ENV !== "production";
var webpack = require('webpack');
var path = require('path');
const PATHS = {
    react: path.join(__dirname, 'node_modules/react/dist/react.min.js'),
    app: path.join(__dirname, 'src'),
    build: path.join(__dirname, './dist')
};

module.exports = {
  context: path.join(__dirname),
  devtool: false,
  entry: "./src/js/root.js",
// 	devtool: false,
// 	sourceMap :false,
// 	devServer: {
// 			inline: false,
// 			historyApiFallback: false,
// 			port: 3000
// 	},
  module: {
    loaders: [
      {
        test: /\.js?$/,
        exclude: /(node_modules)/,
        loader: 'babel-loader',
        query: {
          presets: ['react', 'es2015','stage-1'],
          plugins: ['react-html-attrs'], //添加组件的插件配置
        }
      },
      //下面是使用 ant-design 的配置文件
      { test: /\.css$/, loader: 'style-loader!css-loader' ,
				 options: {
          modules: true,
        }
			},
	  	{
				test: /\.(jpe?g|png|gif|svg)$/i, 
				loader: "file-loader?name=/images/[name].[ext]",
			}
    ]
  },
  output: {
    path: __dirname,
    filename: "./src/bundle.js"
  },
  plugins: [
    new webpack.DefinePlugin({ 
		  'process.env': {
			'NODE_ENV': JSON.stringify('production')
		  }
		}),
		new webpack.optimize.DedupePlugin(), //删除类似的重复代码
		new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }), //最小化一切
		new webpack.optimize.AggressiveMergingPlugin(),//合并块
		
  ],
};