React version upgrade
[sdc.git] / openecomp-ui / webpack.config.js
1 'use strict';
2
3 const path = require('path');
4 const webpack = require('webpack');
5 const proxyServer = require('./proxy-server');
6
7 let localDevConfig = {};
8 try {
9         localDevConfig = require('./devConfig');
10 } catch (e) {}
11 let devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig);
12 let devPort = process.env.PORT || devConfig.port;
13
14 let webpackCommon = require('./webpack.common');
15
16 function getEntrySources(sources) {
17         for (let i in sources) {
18                 if (sources.hasOwnProperty(i)) {
19                         sources[i].push('react-hot-loader/patch');
20                         sources[i].push('webpack-dev-server/client?http://localhost:' + devPort);
21                         sources[i].push('webpack/hot/only-dev-server');
22                 }
23         }
24         return sources;
25 }
26
27 let webpackDevConfig = Object.assign({}, webpackCommon, {
28         entry: getEntrySources(devConfig.bundles),
29         devtool: 'eval-source-map',
30         output: {
31                 path: path.join(__dirname, 'dist'),
32                 publicPath: `http://localhost:${devPort}/onboarding/`,
33                 filename: '[name].js'
34         },
35         devServer: {
36                 port: devPort,
37                 historyApiFallback: true,
38                 publicPath: `http://localhost:${devPort}/onboarding/`,
39                 contentBase: path.join(__dirname, 'dist'),
40                 inline: true,
41                 hot: true,
42                 stats: {
43                         colors: true,
44                         exclude: ['node_modules']
45                 },
46                 setup: proxyServer
47         },
48         plugins: [
49                 new webpack.DefinePlugin({
50                         DEV: true,
51                         DEBUG: true
52                 }),
53                 new webpack.HotModuleReplacementPlugin(),
54                 new webpack.LoaderOptionsPlugin({
55                         options: {
56                                 eslint: {
57                                         configFile: './.eslintrc',
58                                         emitError: true,
59                                         emitWarning: true
60                                 },
61                                 context: '/'
62                         }
63                 })
64         ]
65 });
66
67 module.exports = webpackDevConfig;