2017-07-15 14:58:05 -05:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const HTMLWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
|
|
|
const baseConfig = require('./webpack.config');
|
|
|
|
const env = require('../src/config/env');
|
|
|
|
const _ = require('lodash');
|
|
|
|
const merge = require('webpack-merge');
|
2018-01-28 12:28:03 -05:00
|
|
|
import getPackageVersion from './getPackageVersion';
|
2017-06-25 13:13:39 -05:00
|
|
|
|
2017-07-15 14:58:05 -05:00
|
|
|
const prodConf = {
|
2017-06-25 13:13:39 -05:00
|
|
|
entry: {
|
2017-10-01 07:10:10 -05:00
|
|
|
main: ['babel-polyfill', `${env.SRC_ROOT}/webui/src/index.js`],
|
2017-06-25 13:13:39 -05:00
|
|
|
},
|
|
|
|
|
2017-07-15 14:58:05 -05:00
|
|
|
module: {
|
|
|
|
rules: [],
|
2017-06-25 13:13:39 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
2018-02-19 13:29:14 -05:00
|
|
|
__DEBUG__: false,
|
2017-07-15 14:58:05 -05:00
|
|
|
'process.env.NODE_ENV': '"production"',
|
2018-02-19 13:29:14 -05:00
|
|
|
__APP_VERSION__: `"${getPackageVersion()}"`,
|
2017-06-25 13:13:39 -05:00
|
|
|
}),
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
sourceMap: true,
|
|
|
|
compress: {
|
2017-07-15 15:04:58 -05:00
|
|
|
warnings: false,
|
2017-07-15 14:58:05 -05:00
|
|
|
},
|
2017-06-25 13:13:39 -05:00
|
|
|
}),
|
|
|
|
new ExtractTextPlugin('style.[contenthash].css'),
|
|
|
|
new HTMLWebpackPlugin({
|
2017-07-27 00:35:47 -05:00
|
|
|
title: 'ToReplaceByTitle',
|
2017-06-25 13:13:39 -05:00
|
|
|
filename: 'index.html',
|
|
|
|
verdaccioURL: 'ToReplaceByVerdaccio',
|
2017-07-13 12:55:19 -05:00
|
|
|
template: `${env.SRC_ROOT}/webui/template/index.html`,
|
2017-07-06 09:42:36 -05:00
|
|
|
debug: false,
|
2017-06-25 13:13:39 -05:00
|
|
|
inject: true,
|
|
|
|
}),
|
2017-07-15 14:58:05 -05:00
|
|
|
new webpack.NoEmitOnErrorsPlugin(),
|
|
|
|
],
|
2017-07-13 16:28:45 -05:00
|
|
|
};
|
2017-07-15 14:58:05 -05:00
|
|
|
|
|
|
|
prodConf.module.rules = baseConfig.module.rules
|
|
|
|
.filter((loader) =>
|
|
|
|
Array.isArray(loader.use) && loader.use.find((v) => /css/.test(v.loader.split('-')[0]))
|
|
|
|
).forEach((loader) => {
|
|
|
|
loader.use = ExtractTextPlugin.extract({
|
|
|
|
fallback: 'style-loader',
|
|
|
|
use: _.tail(loader.use),
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = merge(baseConfig, prodConf);
|