webpack.prod.config.js 1.48 KB
'use strict';

const os = require('os');
const path = require('path');
const shelljs = require('shelljs');
const _ = require('lodash');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const config = require('../../package.json');
const distDir = path.join(__dirname, `../dist/${config.name}/${config.version}`);
let baseConfig = require('./webpack.base.config.js');

// cope img font
shelljs.mkdir('-p', distDir);
shelljs.cp('-R', path.join(__dirname, '../img/'), distDir);
shelljs.cp('-R', path.join(__dirname, '../font/'), distDir);

baseConfig = baseConfig('pro');

_.mergeWith(baseConfig, {
    output: {
        path: distDir
    },
    plugins: [
        new ExtractTextPlugin('[name].css'),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"production"'
            }
        }),
        new webpack.optimize.UglifyJsPlugin({
            workers: os.cpus().length,
            ie8: true,
            compress: {
                screw_ie8: false,
                properties: false,
                warnings: false
            },
            output: {
                screw_ie8: false,
                keep_quoted_props: true
            },
            mangle: {
                screw_ie8: false
            },
            comments: false
        })
    ]
}, function customizer(objValue, srcValue) {
    if (_.isArray(objValue)) {
        return objValue.concat(srcValue);
    }
});

module.exports = baseConfig;