[sdc] update to the current code base
[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
11 var currentTime = new Date().getTime();
12
13 const params = {
14     // entryPoints: [
15     //     '/sdc1/scripts/inline',
16     //     '/sdc1/scripts/polyfills',
17     //     '/sdc1/scripts/vendor',
18     //     '/sdc1/scripts/main',
19     //     '/sdc1/scripts/sw-register',
20     //     '/sdc1/scripts/scripts',
21     //     '/sdc1/scripts/styles'
22     // ]
23 };
24
25 const webpackProdConfig = {
26     module: {
27         rules: [
28             {test: /\.(eot|svg)$/, loader: "file-loader?name=/scripts/fonts/[name].[hash:20].[ext]"},
29             {
30                 test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
31                 loader: "url-loader?name=/scripts/images/[name].[hash:20].[ext]&limit=10000"
32             }
33         ]
34     },
35     output: {
36         path: path.join(process.cwd(), "dist"),
37         filename: "[name]." + currentTime + ".bundle.js",
38         chunkFilename: "[id].chunk.js",
39         publicPath: "/sdc1"
40     },
41     plugins: [
42         new webpack.DefinePlugin({
43             __DEBUG__: JSON.stringify(false),
44             __ENV__: JSON.stringify('prod')
45         }),
46
47         new CopyWebpackPlugin([
48             {
49                 from: './src/index.html', transform: function (content, path) {
50                     content = (content + '').replace(/\.bundle/g, '.' + currentTime + '.bundle');
51                     return content;
52                 }
53             }
54         ]),
55         new webpack.optimize.UglifyJsPlugin({
56             beautify: false,
57             mangle: {
58                 screw_ie8: true,
59                 keep_fnames: true
60             },
61             compress: {
62                 warnings: false,
63                 screw_ie8: true
64             },
65             comments: false
66         })
67     ]
68 };
69
70 module.exports = merge(webpackProdConfig, webpackCommonConfig(params));