Fix node filter get methods
[sdc.git] / openecomp-ui / webpack.production.js
1 'use strict';
2
3 let path = require('path');
4 let webpack = require('webpack');
5
6 let cloneDeep = require('lodash/cloneDeep');
7 let assign = require('lodash/assign');
8 let webpackCommon = require('./webpack.common');
9
10 // copying the common config
11 let webpackProdConfig = cloneDeep(webpackCommon);
12 // setting production settings
13 assign(webpackProdConfig, {
14     devtool: undefined,
15     cache: true,
16     output: {
17         path: path.join(__dirname, 'dist'),
18         publicPath: '/onboarding/',
19         filename: '[name].js'
20     },
21     resolveLoader: {
22         modules: [path.join(__dirname, 'node_modules'), path.resolve('.')],
23         alias: {
24             'config-json-loader': 'tools/webpack/config-json-loader/index.js'
25         }
26     },
27     plugins: [
28         new webpack.DefinePlugin({
29             'process.env': {
30                 // This has effect on the react lib size
31                 NODE_ENV: JSON.stringify('production')
32             },
33             DEBUG: false,
34             DEV: false
35         }),
36         new webpack.optimize.UglifyJsPlugin(),
37         new webpack.LoaderOptionsPlugin({
38             options: {
39                 eslint: {
40                     configFile: './.eslintrc',
41                     emitError: true,
42                     emitWarning: true,
43                     failOnError: true
44                 }
45             }
46         })
47     ]
48 });
49
50 webpackProdConfig.module.rules = webpackProdConfig.module.rules.filter(
51     rule =>
52         rule.enforce !== 'pre' ||
53         (rule.enforce === 'pre' && rule.loader !== 'source-map-loader')
54 );
55 webpackProdConfig.module.rules.forEach(loader => {
56     if (loader.use && loader.use[0].loader === 'style-loader') {
57         loader.use = loader.use.map(loaderObj =>
58             loaderObj.loader.replace('?sourceMap', '')
59         );
60     }
61 });
62 webpackProdConfig.module.rules.push({
63     test: /config.json$/,
64     use: [{ loader: 'config-json-loader' }]
65 });
66 module.exports = webpackProdConfig;