blob: bb6f8efaa1e4150f90361210da37b5c15ddc06e5 [file] [log] [blame]
Michael Landoed64b5e2017-06-09 03:19:04 +03001'use strict';
2
3const path = require('path');
4const merge = require('webpack-merge');
5const webpack = require('webpack');
6const ServerConfig = require('./webpack.server');
7const webpackCommonConfig = require('./webpack.common');
8const {GlobCopyWebpackPlugin, BaseHrefWebpackPlugin} = require('@angular/cli/plugins/webpack');
9const CopyWebpackPlugin = require('copy-webpack-plugin');
Michael Lando3c3c8332017-07-20 01:29:49 +030010var CompressionPlugin = require('compression-webpack-plugin');
ys969316a9fce2020-01-19 13:50:02 +020011const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
Michael Lando6e600062017-06-19 19:51:24 +030012var currentTime = new Date().getTime();
13
Michael Lando3c3c8332017-07-20 01:29:49 +030014const params = {};
Michael Landoed64b5e2017-06-09 03:19:04 +030015
16const webpackProdConfig = {
17 module: {
Michael Lando6e600062017-06-19 19:51:24 +030018 rules: [
19 {test: /\.(eot|svg)$/, loader: "file-loader?name=/scripts/fonts/[name].[hash:20].[ext]"},
20 {
21 test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
22 loader: "url-loader?name=/scripts/images/[name].[hash:20].[ext]&limit=10000"
Michael Lando3c3c8332017-07-20 01:29:49 +030023 }
Michael Lando6e600062017-06-19 19:51:24 +030024 ]
Michael Landoed64b5e2017-06-09 03:19:04 +030025 },
26 output: {
27 path: path.join(process.cwd(), "dist"),
Michael Lando6e600062017-06-19 19:51:24 +030028 filename: "[name]." + currentTime + ".bundle.js",
Michael Landoed64b5e2017-06-09 03:19:04 +030029 chunkFilename: "[id].chunk.js",
30 publicPath: "/sdc1"
31 },
Michael Lando6e600062017-06-19 19:51:24 +030032 plugins: [
Michael Landoed64b5e2017-06-09 03:19:04 +030033 new webpack.DefinePlugin({
34 __DEBUG__: JSON.stringify(false),
35 __ENV__: JSON.stringify('prod')
36 }),
Michael Lando6e600062017-06-19 19:51:24 +030037
Michael Landoed64b5e2017-06-09 03:19:04 +030038 new CopyWebpackPlugin([
Michael Lando6e600062017-06-19 19:51:24 +030039 {
40 from: './src/index.html', transform: function (content, path) {
Michael Lando3c3c8332017-07-20 01:29:49 +030041 content = (content + '').replace(/\.bundle.js/g, '.' + currentTime + '.bundle.jsgz');
42
43 return content;
44 }
Michael Lando6e600062017-06-19 19:51:24 +030045 }
Michael Landoed64b5e2017-06-09 03:19:04 +030046 ]),
ys969316a9fce2020-01-19 13:50:02 +020047 new UglifyJSPlugin({}),
Michael Lando3c3c8332017-07-20 01:29:49 +030048 new webpack.optimize.AggressiveMergingPlugin(),//Merge chunks
49 new CompressionPlugin({
50 asset: "[path]gz",
51 algorithm: "gzip",
52 test: /\.js$|\.css$|\.html$/
Michael Landoed64b5e2017-06-09 03:19:04 +030053 })
Michael Lando6e600062017-06-19 19:51:24 +030054 ]
Michael Landoed64b5e2017-06-09 03:19:04 +030055};
56
57module.exports = merge(webpackProdConfig, webpackCommonConfig(params));