[SDC-29] catalog 1707 rebase commit.
[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 const params = {
15     // entryPoints: [
16     //     '/scripts/inline',
17     //     '/scripts/polyfills',
18     //     '/scripts/vendor',
19     //     '/scripts/main',
20     //     '/scripts/sw-register',
21     //     '/scripts/scripts',
22     //     '/scripts/styles'
23     // ]
24 };
25
26 module.exports = function(env) {
27
28     const webpackDevConfig = {
29         devtool: "source-map",
30         devServer: ServerConfig(env),
31         module: {
32             rules: [
33                 { test: /\.(eot|svg)$/, loader: "file-loader?name=scripts/fonts/[name].[hash:20].[ext]" },
34                 { test: /\.(jpg|png|gif|otf|ttf|woff|woff2|cur|ani)$/, loader: "url-loader?name=scripts/images/[name].[hash:20].[ext]&limit=10000" }
35             ]
36         },
37         output: {
38             path: path.join(process.cwd(), "dist"),
39             filename: "[name].bundle.js",
40             chunkFilename: "[id].chunk.js"
41             //publicPath: "/"
42         },
43         plugins: [
44             // Replace /sdc1 inside index.html with '' (because /sdc1 is used only in production).
45             new CopyWebpackPlugin([
46                 { 
47                     from: './src/index.html', transform: function(content, path) {
48                         content = (content+'').replace(/\/sdc1/g,'');
49                         return content;
50                     } 
51                 }  
52             ]),
53             new webpack.DefinePlugin({
54                 __DEBUG__: JSON.stringify(true),
55                 __ENV__: JSON.stringify('dev'),
56                 __HMR__: JSON.stringify('HMR')
57             }),
58             new webpack.HotModuleReplacementPlugin()
59         ]
60
61     };
62
63     return merge(webpackDevConfig, webpackCommonConfig(params));
64 }