Public
Snippet $3 authored by cephei

Webpack Distribution Build Script

Edited
webpack.dist.config.js
/**
 * Created by cephe on 2017/7/8.
 */

const eslintFormatter = require("react-dev-utils/eslintFormatter");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const paths = require("./paths");

module.exports= {
    entry: {
        "common":["moment","pako","g2"],
        "react":["react","react-dom"],
        "antd":["antd"],
        "index.web": [
            paths.devPath + paths.sourcePath + "index.web.js"
        ],
        "login.web": [
            paths.devPath + paths.sourcePath + "login.web.js"
        ]
    },
    output: {
        path:paths.distPath,
        filename:"./js/[name].js",
        publicPath:"/"
    },
    resolve: {
        extensions: ['.js', '.jsx','.css','.less'],
    },
    module: {
        rules: [
            {
                test: /\.(js|jsx)$/,
                exclude: /node_modules/,
                use: [
                    {
                        loader: require.resolve("babel-loader"),
                        options: {
                            plugins: [

                            ],
                            cacheDirectory: true,
                            presets: ['react', 'es2015','stage-1']
                        }
                    }
                ]
            },
            {
                test: /\.(woff|woff2|eot|ttf|svg)$/,
                use: [
                    {
                        loader: require.resolve("url-loader"),
                        options: {
                            limit: 10240,
                            name: paths.fontPath + "[name].[ext]"
                        }
                    }
                ]
            },
            {
                test: /\.css$/,
                use: [
                    {
                        loader: require.resolve("style-loader")
                    },
                    {
                        loader: require.resolve("css-loader"),
                        options: {
                            importLoaders: 1
                        }
                    }
                ]
            },
            {
                test: /\.less$/,
                use: ExtractTextPlugin.extract({
                    use: [
                        {
                            loader: require.resolve("css-loader")
                        },
                        {
                            loader: require.resolve("less-loader"),
                            options: {
                                lessOptions:{
                                    modifyVars: {},
                                    javascriptEnabled: true
                                }
                            }
                        }
                    ],
                    fallback: 'style-loader'
                })
            }
        ]
    },
    plugins:[
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: JSON.stringify('production')
            }
        }),
        new webpack.optimize.UglifyJsPlugin(),
        new ExtractTextPlugin({
            filename: './asset/css/[name].css',
            allChunks: true
        }),
        new webpack.optimize.CommonsChunkPlugin({
            name: ["antd","react","common",'manifest'],
            minChunks:Infinity
        }),
        new webpack.HashedModuleIdsPlugin()
    ]
};