-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
105 lines (100 loc) · 2.19 KB
/
webpack.config.js
File metadata and controls
105 lines (100 loc) · 2.19 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
let dev = {
devtool: 'eval',
entry: [
'webpack-dev-server/client',
'webpack/hot/only-dev-server',
'react-hot-loader/patch',
'./src'
],
output: {
publicPath: '/'
},
devServer: {
proxy: {
'/api': {
target: 'http://api:8080'
}
},
historyApiFallback: true,
hot: true,
host: '0.0.0.0',
port: 9001
},
plugins: [
new HtmlWebpackPlugin({
title: 'Lunch',
template: 'src/template.ejs'
}),
new webpack.HotModuleReplacementPlugin()
],
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
include: path.join(__dirname, 'src'),
query: {
presets: ['react', 'es2015'],
"plugins": ["react-hot-loader/babel"]
}
},
{
test: /\.css$/,
loaders: ['style', 'css'],
include: path.join(__dirname, 'src/styles')
}
]
}
};
/////////////////////////////////////
let prod = {
entry: {
app: './src',
vendor: ['react', 'react-dom', 'react-router', 'redux', 'react-redux']
},
output: {
path: './dist',
filename: '[name].js'
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.optimize.CommonsChunkPlugin({
name:"vendor",
filename:"vendor.js"
}),
new HtmlWebpackPlugin({
title: 'Lunch',
template: 'src/template.ejs'
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new ExtractTextPlugin('styles.css')
],
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
include: path.join(__dirname, 'src'),
query: {
presets: ['react', 'es2015']
}
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style', 'css'),
include: path.join(__dirname, 'src/styles')
}
]
}
};
module.exports = (process.env.npm_lifecycle_event == "front/build-dist" ? prod : dev);