-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.client.js
125 lines (118 loc) · 3.14 KB
/
webpack.config.client.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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const Path = require('path')
const webpack = require('webpack')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const isDev =
process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'stage'
console.log(process.env.NODE_ENV, 'process.env')
module.exports = {
target: 'web',
mode: process.env.NODE_ENV,
entry: './src/client/index.js',
output: {
path: Path.join(__dirname, 'build/client'),
filename: 'bundle.js'
},
module: {
// configuration regarding modules
rules: [
// rules for modules (configure loaders, parser options, etc.)
{
test: /\.(js|jsx)$/,
exclude: /(node_modules)/,
enforce: 'pre',
use: {
loader: 'babel-loader'
}
},
{
test: /\.(js|jsx)$/,
enforce: 'pre',
exclude: /(node_modules)/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.html$/,
use: [
// apply multiple loaders and options
'htmllint-loader',
{
loader: 'html-loader'
}
]
},
{
test: /\.(css|scss|sass)$/,
use: [
MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
sourceMap: true,
publicPath: '/css/'
}
}
// {
// loader: 'sass-loader',
// options: {
// sourceMap: true
// }
// }
]
}
]
},
devServer: {
contentBase: Path.join(__dirname, 'build/client'),
/* proxy: {
'/statics': {
target: 'http://localhost:4000',
pathRewrite: {'^/statics': ''}
}
}, */
// compress: true,
port: 4001
},
// performance: {
// hints: 'warning', // enum
// maxAssetSize: 200000, // int (in bytes),
// maxEntrypointSize: 400000, // int (in bytes)
// assetFilter: function (assetFilename) {
// // Function predicate that provides asset filenames
// return assetFilename.endsWith('.css') || assetFilename.endsWith('.js')
// }
// },
devtool: isDev ? 'cheap-module-source-map' : 'source-map',
plugins: [
new webpack.DefinePlugin({
'process.env.RUN_ENV': JSON.stringify(process.env.RUN_ENV),
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
})
]
}
/* var debug = process.env.NODE_ENV !== 'production'
// var webpack = require('webpack');
module.exports = {
mode: 'production',
context: __dirname,
target: 'web',
resolve: { extensions: ['.jsx', '.js', '.json'] },
devtool: debug ? 'inline-sourcemap' : null,
entry: './src/client/index.js',
output: {
path: Path.join(__dirname, '/build/client'),
filename: 'client.min.js'
},
plugins: debug ? [] : [
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(isDev ? 'development' : (process.env.NODE_ENV === 'production' ? 'production' : 'stage'))
}
})
// new webpack.optimize.DedupePlugin(),
// new webpack.optimize.OccurenceOrderPlugin(),
// new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false })
]
}
*/