-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.server.config.js
72 lines (66 loc) · 1.72 KB
/
webpack.server.config.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
var path = require('path');
var webpack = require('webpack');
var fs = require('fs');
//https://github.com/keokilee/react-typescript-boilerplate
var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
var APP_DIR = path.join(__dirname, 'src');
var config = {
entry: './src/server/index.ts',
output: {
path: __dirname + '/build/server',
filename: 'server.js'
},
resolve: {
modulesDirectories: ['node_modules'],
// Add `.ts` and `.tsx` as a resolvable extension.
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js', '.jsx'],
},
target: 'node',
externals: nodeModules,
module: {
loaders: [{
test: /\.tsx?$/,
loaders: ['babel', 'ts'],
include: APP_DIR
}, {
test: /\.jsx?$/,
loaders: ['babel'],
include: APP_DIR
}, {
test: /\.json$/,
loader: "json"
}, {
test: /\.svg$/,
loader: require.resolve('./webpacksvg-loader')
}]
},
ts: {
compiler: 'typescript'
},
plugins: [
new webpack.BannerPlugin('Build: ' + new Date()),
//new webpack.ContextReplacementPlugin(/loadContainerAsync/, ''),
new webpack.NormalModuleReplacementPlugin(/^bundle\?.*$/, function (result) {
result.request = result.request.replace(/^bundle\?lazy&[^\!]*\!(.*)$/, "$1");
}),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV !== 'undefined'
? process.env.NODE_ENV
: 'production'
)
}
})
]
}
if (process.env.NODE_ENV === 'development') {
config.devtool = "#source-map";
}
module.exports = config;