blob: a593e371197491518c15f4a1c316307b55d23bbf [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');
Michael Lando6e600062017-06-19 19:51:24 +030011var currentTime = new Date().getTime();
12
Michael Lando3c3c8332017-07-20 01:29:49 +030013const params = {};
Michael Landoed64b5e2017-06-09 03:19:04 +030014
15const webpackProdConfig = {
16 module: {
Michael Lando6e600062017-06-19 19:51:24 +030017 rules: [
18 {test: /\.(eot|svg)$/, loader: "file-loader?name=/scripts/fonts/[name].[hash:20].[ext]"},
19 {
20 test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
21 loader: "url-loader?name=/scripts/images/[name].[hash:20].[ext]&limit=10000"
Michael Lando3c3c8332017-07-20 01:29:49 +030022 }
Michael Lando6e600062017-06-19 19:51:24 +030023 ]
Michael Landoed64b5e2017-06-09 03:19:04 +030024 },
25 output: {
26 path: path.join(process.cwd(), "dist"),
Michael Lando6e600062017-06-19 19:51:24 +030027 filename: "[name]." + currentTime + ".bundle.js",
Michael Landoed64b5e2017-06-09 03:19:04 +030028 chunkFilename: "[id].chunk.js",
29 publicPath: "/sdc1"
30 },
Michael Lando6e600062017-06-19 19:51:24 +030031 plugins: [
Michael Landoed64b5e2017-06-09 03:19:04 +030032 new webpack.DefinePlugin({
33 __DEBUG__: JSON.stringify(false),
34 __ENV__: JSON.stringify('prod')
35 }),
Michael Lando6e600062017-06-19 19:51:24 +030036
Michael Landoed64b5e2017-06-09 03:19:04 +030037 new CopyWebpackPlugin([
Michael Lando6e600062017-06-19 19:51:24 +030038 {
39 from: './src/index.html', transform: function (content, path) {
Michael Lando3c3c8332017-07-20 01:29:49 +030040 content = (content + '').replace(/\.bundle.js/g, '.' + currentTime + '.bundle.jsgz');
41
42 return content;
43 }
Michael Lando6e600062017-06-19 19:51:24 +030044 }
Michael Landoed64b5e2017-06-09 03:19:04 +030045 ]),
Michael Lando6e600062017-06-19 19:51:24 +030046 new webpack.optimize.UglifyJsPlugin({
Michael Landoed64b5e2017-06-09 03:19:04 +030047 beautify: false,
48 mangle: {
49 screw_ie8: true,
50 keep_fnames: true
51 },
52 compress: {
53 warnings: false,
54 screw_ie8: true
55 },
56 comments: false
Michael Lando3c3c8332017-07-20 01:29:49 +030057 }),
58 new webpack.optimize.AggressiveMergingPlugin(),//Merge chunks
59 new CompressionPlugin({
60 asset: "[path]gz",
61 algorithm: "gzip",
62 test: /\.js$|\.css$|\.html$/
Michael Landoed64b5e2017-06-09 03:19:04 +030063 })
Michael Lando6e600062017-06-19 19:51:24 +030064 ]
Michael Landoed64b5e2017-06-09 03:19:04 +030065};
66
67module.exports = merge(webpackProdConfig, webpackCommonConfig(params));