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 |
| 13 | assign( webpackProdConfig, { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 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 | |
Avi Ziv | b8e2faf | 2017-07-18 19:45:38 +0300 | [diff] [blame] | 50 | webpackProdConfig.module.rules = webpackProdConfig.module.rules.filter(rule => ((rule.enforce !== 'pre') || (rule.enforce === 'pre' && rule.loader !== 'source-map-loader'))); |
| 51 | webpackProdConfig.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 | }); |
| 56 | webpackProdConfig.module.rules.push({test: /config.json$/, use: [{loader:'config-json-loader'}]}); |
| 57 | module.exports = webpackProdConfig; |