Merge "Replace FileUtils.toByteArray() with IOUtils"
[sdc.git] / catalog-ui / webpack.production.js
1 'use strict';
2
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 var currentTime = new Date().getTime();
12
13 const params = {};
14
15 const webpackProdConfig = {
16     module: {
17         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"
22     }
23         ]
24     },
25     output: {
26         path: path.join(process.cwd(), "dist"),
27         filename: "[name]." + currentTime + ".bundle.js",
28         chunkFilename: "[id].chunk.js",
29         publicPath: "/sdc1"
30     },
31     plugins: [
32         new webpack.DefinePlugin({
33             __DEBUG__: JSON.stringify(false),
34             __ENV__: JSON.stringify('prod')
35         }),
36
37         new CopyWebpackPlugin([
38             {
39                 from: './src/index.html', transform: function (content, path) {
40                 content = (content + '').replace(/\.bundle.js/g, '.' + currentTime + '.bundle.jsgz');
41
42                 return content;
43             }
44             }
45         ]),
46         new webpack.optimize.UglifyJsPlugin({
47             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
57         }),
58         new webpack.optimize.AggressiveMergingPlugin(),//Merge chunks
59         new CompressionPlugin({
60             asset: "[path]gz",
61             algorithm: "gzip",
62             test: /\.js$|\.css$|\.html$/
63         })
64     ]
65 };
66
67 module.exports = merge(webpackProdConfig, webpackCommonConfig(params));