-
Notifications
You must be signed in to change notification settings - Fork 172
/
Copy pathwebpack.config.js
57 lines (50 loc) · 1.44 KB
/
webpack.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
const path = require('path');
let libraryName = 'json-graphql-server';
let plugins = [];
let outputFile;
if (process.env.NODE_ENV === 'production') {
outputFile = target => `${libraryName}.${target}.min.js`;
} else {
outputFile = target => `${libraryName}.${target}.js`;
}
const defaultConfig = {
devtool: 'source-map',
mode: process.env.NODE_ENV === 'production' ? 'production' : 'development',
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/,
},
],
},
resolve: {
modules: [path.resolve('./node_modules'), path.resolve('./src')],
extensions: ['.mjs', '.json', '.js'],
},
plugins,
};
const serverConfig = Object.assign({}, defaultConfig, {
target: 'node',
entry: __dirname + '/src/node.js',
output: {
path: path.resolve(__dirname, 'lib'),
filename: outputFile('node'),
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
},
});
const clientConfig = Object.assign({}, defaultConfig, {
target: 'web',
entry: __dirname + '/src/client.js',
output: {
path: path.resolve(__dirname, 'lib'),
filename: outputFile('client'),
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true,
},
});
module.exports = [serverConfig, clientConfig];