blob: 2dea2170ae2e89ad9daaa8fc01ea343819f4a522 [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001'use strict';
2
3let path = require('path');
4let webpack = require('webpack');
5
Avi Zivb8e2faf2017-07-18 19:45:38 +03006let cloneDeep = require('lodash/cloneDeep');
7let assign = require('lodash/assign');
AviZi280f8012017-06-09 02:39:56 +03008let webpackCommon = require('./webpack.common');
9
Avi Zivb8e2faf2017-07-18 19:45:38 +030010// copying the common config
11let webpackProdConfig = cloneDeep(webpackCommon);
12// setting production settings
13assign( webpackProdConfig, {
AviZi280f8012017-06-09 02:39:56 +030014 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
Avi Zivb8e2faf2017-07-18 19:45:38 +030050webpackProdConfig.module.rules = webpackProdConfig.module.rules.filter(rule => ((rule.enforce !== 'pre') || (rule.enforce === 'pre' && rule.loader !== 'source-map-loader')));
51webpackProdConfig.module.rules.forEach(loader => {
52 if (loader.use && loader.use[0].loader === 'style-loader') {
53 loader.use = loader.use.map(loaderObj => loaderObj.loader.replace('?sourceMap', ''));
54 }
55});
56webpackProdConfig.module.rules.push({test: /config.json$/, use: [{loader:'config-json-loader'}]});
57module.exports = webpackProdConfig;