blob: 22da77e6ed33527e49c806ac95b540d0af3f7bc8 [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
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020013assign(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 ]
AviZi280f8012017-06-09 02:39:56 +030048});
49
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020050webpackProdConfig.module.rules = webpackProdConfig.module.rules.filter(
51 rule =>
52 rule.enforce !== 'pre' ||
53 (rule.enforce === 'pre' && rule.loader !== 'source-map-loader')
54);
Avi Zivb8e2faf2017-07-18 19:45:38 +030055webpackProdConfig.module.rules.forEach(loader => {
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020056 if (loader.use && loader.use[0].loader === 'style-loader') {
57 loader.use = loader.use.map(loaderObj =>
58 loaderObj.loader.replace('?sourceMap', '')
59 );
60 }
Avi Zivb8e2faf2017-07-18 19:45:38 +030061});
Einav Weiss Keidar7fdf7332018-03-20 14:45:40 +020062webpackProdConfig.module.rules.push({
63 test: /config.json$/,
64 use: [{ loader: 'config-json-loader' }]
65});
Avi Zivb8e2faf2017-07-18 19:45:38 +030066module.exports = webpackProdConfig;