2017-07-15 14:58:05 -05:00
|
|
|
const webpack = require('webpack');
|
|
|
|
const HTMLWebpackPlugin = require('html-webpack-plugin');
|
2018-04-26 22:52:24 -05:00
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const UglifyJsWebpackPlugin = require('uglifyjs-webpack-plugin');
|
2018-05-27 07:34:17 -05:00
|
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
2017-07-15 14:58:05 -05:00
|
|
|
const baseConfig = require('./webpack.config');
|
|
|
|
const env = require('../src/config/env');
|
|
|
|
const _ = require('lodash');
|
|
|
|
const merge = require('webpack-merge');
|
2018-06-25 02:45:57 -05:00
|
|
|
const getPackageJson = require('./getPackageJson');
|
|
|
|
|
|
|
|
const {
|
|
|
|
version,
|
|
|
|
name,
|
|
|
|
license,
|
|
|
|
} = getPackageJson('version', 'name', 'license');
|
|
|
|
|
|
|
|
const banner = `
|
|
|
|
Name: [name]
|
|
|
|
Generated on: ${Date.now()}
|
|
|
|
Package: ${name}
|
|
|
|
Version: v${version}
|
|
|
|
License: ${license}
|
|
|
|
`;
|
2017-06-25 13:13:39 -05:00
|
|
|
|
2017-07-15 14:58:05 -05:00
|
|
|
const prodConf = {
|
2018-04-26 22:52:24 -05:00
|
|
|
mode: 'production',
|
|
|
|
|
2017-06-25 13:13:39 -05:00
|
|
|
entry: {
|
2018-07-17 14:22:44 -05:00
|
|
|
main: ['babel-polyfill', 'whatwg-fetch', `${env.SRC_ROOT}/webui/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-06-25 02:45:57 -05:00
|
|
|
__APP_VERSION__: `"${version}"`,
|
2017-06-25 13:13:39 -05:00
|
|
|
}),
|
2018-04-26 22:52:24 -05:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'style.[contenthash].css',
|
2017-06-25 13:13:39 -05:00
|
|
|
}),
|
|
|
|
new HTMLWebpackPlugin({
|
2017-07-27 00:35:47 -05:00
|
|
|
title: 'ToReplaceByTitle',
|
2018-07-29 11:30:08 -05:00
|
|
|
scope: 'ToReplaceByScope',
|
2017-06-25 13:13:39 -05:00
|
|
|
filename: 'index.html',
|
2018-05-25 00:42:18 -05:00
|
|
|
favicon: `${env.SRC_ROOT}/webui/template/favicon.ico`,
|
2017-06-25 13:13:39 -05:00
|
|
|
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,
|
|
|
|
}),
|
2018-06-25 02:45:57 -05:00
|
|
|
new webpack.BannerPlugin(banner),
|
2017-07-15 14:58:05 -05:00
|
|
|
],
|
2018-04-26 22:52:24 -05:00
|
|
|
|
|
|
|
optimization: {
|
|
|
|
minimizer: [
|
|
|
|
new UglifyJsWebpackPlugin({
|
|
|
|
sourceMap: true,
|
|
|
|
}),
|
2018-05-27 07:34:17 -05:00
|
|
|
new OptimizeCSSAssetsPlugin({}),
|
2018-04-26 22:52:24 -05:00
|
|
|
],
|
|
|
|
},
|
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) => {
|
2018-04-26 22:52:24 -05:00
|
|
|
loader.use = [MiniCssExtractPlugin.loader].concat(_.tail(loader.use));
|
2018-06-25 02:45:57 -05:00
|
|
|
});
|
2017-07-15 14:58:05 -05:00
|
|
|
|
|
|
|
module.exports = merge(baseConfig, prodConf);
|