| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 | const webpack = require('webpack');const path = require('path');const ExtractTextPlugin = require("extract-text-webpack-plugin");const HtmlWebpackPlugin = require('html-webpack-plugin');let theme = {    '@primary-color': '#1DA57A',    '@link-color': '#1DA57A',    '@border-radius-base': '8px'};module.exports = {    entry: {        'user/index': './js/user/index.js',        'user/login': './js/user/login.js',        'admin/index':'./js/admin/index.js',        vendors: ['jquery']    },    output: {        path: path.resolve(__dirname, './build'),        filename: '[name].js',    },    module: {        loaders: [{            test: /\.jsx?$/,            exclude: /node_modules/,            loader: 'babel-loader',            query: {                "presets": ["es2015", "react"],                "plugins": [                    ["antd", {                        "style": true                    }]                ]            }            //loaders: ['babel-loader?presets[]=es2015,presets[]=react']         }, {            test: /\.css$/,            loader: ExtractTextPlugin.extract('style-loader', 'css-loader')        }, {            test: /\.less$/,            loader: ExtractTextPlugin.extract('style', `css!less?{"modifyVars":${JSON.stringify(theme)}}`)        }, {            test: /\.(png|jpg)$/,            loader: 'url?limit=8192&name=[path][name].[ext]'        }]    },    resolve: {        extensions: ['', '.js', '.jsx']    },    plugins: [        //这个使用uglifyJs压缩你的js代码        new webpack.optimize.UglifyJsPlugin({            minimize: true,            compress: {                warnings: true            }        }),        new webpack.DefinePlugin({            "process.env": {                 NODE_ENV: JSON.stringify("production")             }        }),        new ExtractTextPlugin('[name].css', {            allChunks: true        }),        //把入口文件里面的数组打包成verdors.js        new webpack.optimize.CommonsChunkPlugin('vendors', 'vendors.js'),        //user        new HtmlWebpackPlugin({            title: 'user_index',            filename: 'user/index.html',            template: './template/template.html',            chunks:['user/index','vendors']        }),        new HtmlWebpackPlugin({            title: 'user_login',            filename: 'user/login.html',            template: './template/template.html',            chunks:['user/login','vendors']        }),        //admin        new HtmlWebpackPlugin({            title: 'admin_index',            filename: 'admin/index.html',            template: './template/template.html',            chunks:['admin/index','vendors']        })    ]};
 |