AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | 'use strict'; |
| 2 | |
| 3 | let path = require('path'); |
| 4 | let webpack = require('webpack'); |
| 5 | |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 6 | let cloneDeep = require('lodash/cloneDeep'); |
| 7 | let assign = require('lodash/assign'); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 8 | let webpackCommon = require('./webpack.common'); |
| 9 | |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 10 | // copying the common config |
| 11 | let webpackProdConfig = cloneDeep(webpackCommon); |
| 12 | // setting production settings |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 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 | ] |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 48 | }); |
| 49 | |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 50 | webpackProdConfig.module.rules = webpackProdConfig.module.rules.filter( |
| 51 | rule => |
| 52 | rule.enforce !== 'pre' || |
| 53 | (rule.enforce === 'pre' && rule.loader !== 'source-map-loader') |
| 54 | ); |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 55 | webpackProdConfig.module.rules.forEach(loader => { |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 56 | if (loader.use && loader.use[0].loader === 'style-loader') { |
| 57 | loader.use = loader.use.map(loaderObj => |
| 58 | loaderObj.loader.replace('?sourceMap', '') |
| 59 | ); |
| 60 | } |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 61 | }); |
Einav Weiss Keidar | 7fdf733 | 2018-03-20 14:45:40 +0200 | [diff] [blame^] | 62 | webpackProdConfig.module.rules.push({ |
| 63 | test: /config.json$/, |
| 64 | use: [{ loader: 'config-json-loader' }] |
| 65 | }); |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 66 | module.exports = webpackProdConfig; |