Fix 'Changing VFC version on template wipes previously assigned property values based...
[sdc.git] / catalog-ui / webpack.config.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 {BaseHrefWebpackPlugin} = require('@angular/cli/plugins/webpack');
9 const CopyWebpackPlugin = require('copy-webpack-plugin');
10
11 // Print server configuration
12 //process.stdout.write('webpack.server: ' + JSON.stringify(ServerConfig) + '\n');
13 //process.stdout.write('webpack.common: ' + JSON.stringify(webpackCommonConfig) + '\n');
14 var currentTime = new Date().getTime();
15
16 const params = {
17     // entryPoints: [
18     //     '/scripts/inline',
19     //     '/scripts/polyfills',
20     //     '/scripts/vendor',
21     //     '/scripts/main',
22     //     '/scripts/sw-register',
23     //     '/scripts/scripts',
24     //     '/scripts/styles'
25     // ]
26 };
27
28 module.exports = function (env) {
29
30     const webpackDevConfig = {
31         devtool: "source-map",
32         devServer: ServerConfig(env),
33         module: {
34             rules: [
35                 {test: /\.(eot|svg)$/, loader: "file-loader?name=scripts/fonts/[name].[hash:20].[ext]"},
36                 {
37                     test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/,
38                     loader: "url-loader?name=scripts/images/[name].[hash:20].[ext]&limit=10000"
39                 }
40             ]
41         },
42         output: {
43             path: path.join(process.cwd(), "dist"),
44             filename: "[name]." + currentTime + ".bundle.js",
45             chunkFilename: "[id].chunk.js"
46             //publicPath: "/"
47         },
48         plugins: [
49
50             // Replace /sdc1 inside index.html with '' (because /sdc1 is used only in production).
51             new CopyWebpackPlugin([
52                 {
53                     from: './src/index.html', transform: function (content, path) {
54                     content = (content + '').replace(/\/sdc1/g, '');
55                     content = (content + '').replace(/\.bundle/g, '.' + currentTime + '.bundle');
56                     return content;
57                    }
58                 }
59             ]),
60             new webpack.DefinePlugin({
61                 __DEBUG__: JSON.stringify(true),
62                 __ENV__: JSON.stringify('dev'),
63                 __HMR__: JSON.stringify('HMR')
64             }),
65             new webpack.HotModuleReplacementPlugin()
66         ]
67
68     };
69
70     return merge(webpackDevConfig, webpackCommonConfig(params));
71 }