blob: c723a7a86c8abd0ea08c43ecebec8a9ff04b0135 [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)) {
19 sources[i].push('webpack-dev-server/client?http://localhost:' + devPort);
20 sources[i].push('webpack/hot/only-dev-server');
Michael Landoefa037d2017-02-19 12:57:33 +020021 }
AviZi280f8012017-06-09 02:39:56 +030022 }
23 return sources;
24}
25
26let webpackDevConfig = Object.assign({}, webpackCommon, {
27 entry: getEntrySources(devConfig.bundles),
28 devtool: 'eval-source-map',
Michael Landoefa037d2017-02-19 12:57:33 +020029 output: {
AviZi280f8012017-06-09 02:39:56 +030030 path: path.join(__dirname, 'dist'),
Michael Landoefa037d2017-02-19 12:57:33 +020031 publicPath: `http://localhost:${devPort}/onboarding/`,
32 filename: '[name].js'
33 },
34 devServer: {
35 port: devPort,
36 historyApiFallback: true,
37 publicPath: `http://localhost:${devPort}/onboarding/`,
AviZi280f8012017-06-09 02:39:56 +030038 contentBase: path.join(__dirname, 'dist'),
Michael Landoefa037d2017-02-19 12:57:33 +020039 hot: true,
Michael Landoefa037d2017-02-19 12:57:33 +020040 inline: true,
Michael Landoefa037d2017-02-19 12:57:33 +020041 stats: {
AviZi280f8012017-06-09 02:39:56 +030042 colors: true,
43 exclude: ['node_modules']
44 },
45 setup: proxyServer
Michael Landoefa037d2017-02-19 12:57:33 +020046 },
47 plugins: [
48 new webpack.DefinePlugin({
49 DEV: true,
50 DEBUG: true
51 }),
52 new webpack.HotModuleReplacementPlugin(),
AviZi280f8012017-06-09 02:39:56 +030053 new webpack.LoaderOptionsPlugin({
54 options: {
55 eslint: {
56 configFile: './.eslintrc',
57 emitError: true,
58 emitWarning: true
59 },
60 context: '/'
Michael Landoefa037d2017-02-19 12:57:33 +020061 }
62 })
63 ]
AviZi280f8012017-06-09 02:39:56 +030064});
Michael Landoefa037d2017-02-19 12:57:33 +020065
AviZi280f8012017-06-09 02:39:56 +030066module.exports = webpackDevConfig;