aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/webpack.production.js
blob: 2dea2170ae2e89ad9daaa8fc01ea343819f4a522 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';

let path = require('path');
let webpack = require('webpack');

let cloneDeep = require('lodash/cloneDeep');
let assign = require('lodash/assign');
let webpackCommon = require('./webpack.common');

// copying the common config
let webpackProdConfig = cloneDeep(webpackCommon);
// setting production settings
assign( webpackProdConfig, {
	devtool: undefined,
	cache: true,
	output: {
		path: path.join(__dirname, 'dist'),
		publicPath: '/onboarding/',
		filename: '[name].js'
	},
	resolveLoader: {
		modules: [path.join(__dirname, 'node_modules'), path.resolve('.')],
		alias: {
			'config-json-loader': 'tools/webpack/config-json-loader/index.js'
		}
	},
	plugins: [
		new webpack.DefinePlugin({
			'process.env': {
				// This has effect on the react lib size
				'NODE_ENV': JSON.stringify('production')
			},
			DEBUG: false,
			DEV: false
		}),
		new webpack.optimize.UglifyJsPlugin(),
		new webpack.LoaderOptionsPlugin({
			options: {
				eslint: {
					configFile: './.eslintrc',
					emitError: true,
					emitWarning: true,
					failOnError: true
				}
			}
		})
	]
});

webpackProdConfig.module.rules = webpackProdConfig.module.rules.filter(rule => ((rule.enforce !== 'pre') || (rule.enforce === 'pre' && rule.loader !== 'source-map-loader')));
webpackProdConfig.module.rules.forEach(loader => {
	if (loader.use && loader.use[0].loader === 'style-loader') {
		loader.use = loader.use.map(loaderObj => loaderObj.loader.replace('?sourceMap', ''));
	}
});
webpackProdConfig.module.rules.push({test: /config.json$/, use: [{loader:'config-json-loader'}]});
module.exports = webpackProdConfig;