-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.backend.js
67 lines (59 loc) · 1.87 KB
/
webpack.config.backend.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
var webpack = require('webpack');
var path = require('path');
var fs = require('fs');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var debug = process.env.NODE_ENV !== "production";
var SERVER_DIR = path.resolve(__dirname, 'src/server');
var BUILD_DIR = path.resolve(__dirname, 'build');
const envPlug = new webpack.EnvironmentPlugin({
NODE_ENV : debug ? "development" : "production",
UBAT_IP: "localhost",
UBAT_PORT: "13750"
});
const copyPlug = new CopyWebpackPlugin([
{from: "./migrations", to: "migrations/"},
]);
var config = [
{
name: 'server',
entry: SERVER_DIR + '/server_promises.js',
target: 'node',
node: {
__filename: false,
__dirname: false //__dirname points to the directory of the bundled file
},
output: {
path: BUILD_DIR,
filename: 'server.js'
},
// dont bundle sqlite and sqlite3 because native modules don't want to be bundled
externals: {
sqlite: 'commonjs sqlite',
sqlite3: 'commonjs sqlite3'
},
module: {
loaders : [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ["es2017-node7"],
plugins: ['transform-decorators-legacy', 'transform-class-properties']
}
}
]
},
plugins: debug ? [
envPlug,
copyPlug,
new webpack.BannerPlugin( {
banner: 'require("source-map-support").install();',
raw: true,
entryOnly: false }),
]
: [envPlug, copyPlug],
devtool: debug ? 'sourcemap' : false
}
];
module.exports = config;