3 const path = require('path');
4 const merge = require('webpack-merge');
5 const webpack = require('webpack');
6 const ServerConfig = require('./webpack.server');
7 const webpackCommonConfig = require('./webpack.common');
8 const {GlobCopyWebpackPlugin, BaseHrefWebpackPlugin} = require('@angular/cli/plugins/webpack');
9 const CopyWebpackPlugin = require('copy-webpack-plugin');
10 var CompressionPlugin = require('compression-webpack-plugin');
11 const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
12 var currentTime = new Date().getTime();
16 const webpackProdConfig = {
19 {test: /\.(eot|svg)$/, loader: "file-loader?name=/scripts/fonts/[name].[hash:20].[ext]"},
21 test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
22 loader: "url-loader?name=/scripts/images/[name].[hash:20].[ext]&limit=10000"
27 path: path.join(process.cwd(), "dist"),
28 filename: "[name]." + currentTime + ".bundle.js",
29 chunkFilename: "[id].chunk.js",
33 new webpack.DefinePlugin({
34 __DEBUG__: JSON.stringify(false),
35 __ENV__: JSON.stringify('prod')
38 new CopyWebpackPlugin([
40 from: './src/index.html', transform: function (content, path) {
41 content = (content + '').replace(/\.bundle.js/g, '.' + currentTime + '.bundle.jsgz');
47 new UglifyJSPlugin({}),
48 new webpack.optimize.AggressiveMergingPlugin(),//Merge chunks
49 new CompressionPlugin({
52 test: /\.js$|\.css$|\.html$/
57 module.exports = merge(webpackProdConfig, webpackCommonConfig(params));