webpack.prod.config.js 955 Bytes
'use strict';

const path = require('path');
const os = require('os');
const shelljs = require('shelljs');
const webpack = require('webpack');
const UglifyJsParallelPlugin = require('webpack-uglify-parallel');
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');
baseConfig.output.path = distDir;
baseConfig.plugins.push(
    new webpack.DefinePlugin({
        'process.env': {
            NODE_ENV: '"production"'
        }
    }),
    new UglifyJsParallelPlugin({
        workers: os.cpus().length,
        compress: {
            warnings: false
        },
        comments: false
    })
);

module.exports = baseConfig;