forked from jsjaspreet/fitness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.webpack.js
69 lines (64 loc) · 1.59 KB
/
client.webpack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const WebpackMd5Hash = require('webpack-md5-hash')
const vendor_libs = [
'react', 'babel-polyfill', 'react-dom', 'react-router-dom'
]
let plugins = [
new webpack.optimize.CommonsChunkPlugin({
names: ['vendor', 'manifest']
}),
new WebpackMd5Hash(),
new HtmlWebpackPlugin({
template: 'src/server/index.html',
title: 'Starter Project',
favicon: './favicon.ico'
})
]
if (process.env.NODE_ENV === 'production') {
plugins = [...plugins,
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify('production')
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: false
})]
}
module.exports = {
entry: {
bundle: ['babel-polyfill', './src/client/index.js'],
vendor: vendor_libs
},
output: {
path: path.join(__dirname, 'build'),
filename: '[chunkhash].[id].[name].js',
publicPath: process.env.NODE_ENV === 'dev' ? '' : '/build/'
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader?modules'],
exclude: /node_modules/
}
]
},
devtool: 'cheap-module-source-map',
plugins: plugins,
devServer: {
historyApiFallback: true,
proxy: {
"/api": "http://localhost:9090",
"/graphql": "http://localhost:9090"
}
}
}