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

const path = require('path');
const shelljs = require('shelljs');
const webpack = require('webpack');
const merge = require('webpack-merge');
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);
shelljs.cp('-R', path.join(__dirname, './dll/*'), distDir);

baseConfig = baseConfig('pro');

module.exports = merge(baseConfig, {
    output: {
        path: distDir
    },
    plugins: [
        new ExtractTextPlugin('[name].css'),
        new webpack.DefinePlugin({
            'process.env': {
                NODE_ENV: '"production"'
            }
        }),
        new webpack.optimize.UglifyJsPlugin({
            parallel: true,
            sourceMap: true,
            uglifyOptions: {
                compress: {
                    warnings: false
                },
                comments: false
            }
        })
    ]
});