-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
117 lines (109 loc) · 2.45 KB
/
webpack.config.js
File metadata and controls
117 lines (109 loc) · 2.45 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
106
107
108
109
110
111
112
113
114
115
116
117
const path = require('path');
const webpack = require('webpack');
const src = path.join(__dirname, './src');
const dist = path.join(__dirname, './dist');
const distPublic = path.join(__dirname, './dist/public');
const client = {
entry: [
'webpack-dev-server/client?http://localhost:9000',
'webpack/hot/only-dev-server',
'react-hot-loader/patch',
'babel-polyfill',
'./src/client/client',
],
devtool: 'cheap-module-eval-source-map',
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx'],
},
output: {
path: distPublic,
filename: 'client.js',
publicPath: '/public/',
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors',
filename: 'vendors.js',
minChunks: (m) => {
if (typeof m.userRequest !== 'string') {
return false;
}
return m.userRequest.indexOf(/node_modules/) >= 0;
},
}),
],
module: {
loaders: [
{
test: /\.css$/,
include: [src],
loaders: [
'style?sourceMap',
'css?modules&importLoaders=1&localIdentName=[name]--[local]--[hash:base64:5]',
'postcss',
],
},
{
test: /\.js$/,
include: [src],
loaders: ['babel'],
},
],
},
postcss: [
require('precss')({}),
require('autoprefixer')({}),
require('cssnano')({}),
],
};
const server = {
entry: [
'babel-polyfill',
'./src/server/server',
],
devtool: 'cheap-eval-source-map',
cache: true,
debug: true,
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js', '.jsx'],
},
output: {
path: dist,
filename: 'server.js',
libraryTarget: 'commonjs2',
},
externals: [
// All files not starting with `./` are considered external and will not
// be bundled in the server script (node_modules installation required)
(context, request, cb) => {
const isExternal = request.match(/^[a-z][a-z\/\.\-0-9]*$/i);
cb(null, Boolean(isExternal));
},
],
target: 'node',
node: {
console: false,
global: false,
process: false,
Buffer: false,
__filename: false,
__dirname: false,
},
plugins: [
],
module: {
loaders: [
{
test: /\.js$/,
loaders: ['babel'],
include: src,
},
{
test: /\.json$/,
loader: 'json',
},
],
},
};
module.exports = [client, server];