blob: a8910ff733c9ba49886dfc7240c2dfe26b358cd8 [file] [log] [blame]
Michael Landoefa037d2017-02-19 12:57:33 +02001'use strict';
2
AviZi280f8012017-06-09 02:39:56 +03003const path = require('path');
4const webpack = require('webpack');
5const proxyServer = require('./proxy-server');
Michael Landoefa037d2017-02-19 12:57:33 +02006
AviZi280f8012017-06-09 02:39:56 +03007let localDevConfig = {};
Michael Landoefa037d2017-02-19 12:57:33 +02008try {
9 localDevConfig = require('./devConfig');
AviZi280f8012017-06-09 02:39:56 +030010} catch (e) {}
11let devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig);
12let devPort = process.env.PORT || devConfig.port;
Michael Landoefa037d2017-02-19 12:57:33 +020013
AviZi280f8012017-06-09 02:39:56 +030014let webpackCommon = require('./webpack.common');
15
16function getEntrySources(sources) {
17 for (let i in sources) {
18 if (sources.hasOwnProperty(i)) {
svishnev1eb66b72018-01-11 14:39:45 +020019 sources[i].push('react-hot-loader/patch');
AviZi280f8012017-06-09 02:39:56 +030020 sources[i].push('webpack-dev-server/client?http://localhost:' + devPort);
21 sources[i].push('webpack/hot/only-dev-server');
Michael Landoefa037d2017-02-19 12:57:33 +020022 }
AviZi280f8012017-06-09 02:39:56 +030023 }
24 return sources;
25}
26
27let webpackDevConfig = Object.assign({}, webpackCommon, {
28 entry: getEntrySources(devConfig.bundles),
29 devtool: 'eval-source-map',
Michael Landoefa037d2017-02-19 12:57:33 +020030 output: {
AviZi280f8012017-06-09 02:39:56 +030031 path: path.join(__dirname, 'dist'),
Michael Landoefa037d2017-02-19 12:57:33 +020032 publicPath: `http://localhost:${devPort}/onboarding/`,
33 filename: '[name].js'
34 },
35 devServer: {
36 port: devPort,
37 historyApiFallback: true,
38 publicPath: `http://localhost:${devPort}/onboarding/`,
AviZi280f8012017-06-09 02:39:56 +030039 contentBase: path.join(__dirname, 'dist'),
Michael Landoefa037d2017-02-19 12:57:33 +020040 inline: true,
svishnev1eb66b72018-01-11 14:39:45 +020041 hot: true,
Michael Landoefa037d2017-02-19 12:57:33 +020042 stats: {
AviZi280f8012017-06-09 02:39:56 +030043 colors: true,
44 exclude: ['node_modules']
45 },
Einav Weiss Keidard2f57942018-02-14 14:00:07 +020046 before: proxyServer
Michael Landoefa037d2017-02-19 12:57:33 +020047 },
48 plugins: [
49 new webpack.DefinePlugin({
50 DEV: true,
51 DEBUG: true
52 }),
53 new webpack.HotModuleReplacementPlugin(),
AviZi280f8012017-06-09 02:39:56 +030054 new webpack.LoaderOptionsPlugin({
55 options: {
56 eslint: {
57 configFile: './.eslintrc',
58 emitError: true,
59 emitWarning: true
60 },
61 context: '/'
Michael Landoefa037d2017-02-19 12:57:33 +020062 }
63 })
64 ]
AviZi280f8012017-06-09 02:39:56 +030065});
Michael Landoefa037d2017-02-19 12:57:33 +020066
AviZi280f8012017-06-09 02:39:56 +030067module.exports = webpackDevConfig;