-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
webpack.config.js
57 lines (54 loc) · 1.71 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');
const webpack = require('webpack');
const TerserPlugin = require('terser-webpack-plugin');
const { options: postgraphileOptions } = require('./src/postgraphileOptions.js');
module.exports = {
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
library: '',
libraryTarget: 'commonjs',
},
mode: 'production',
target: 'node',
plugins: [
// Prevent loading pg-native (in a weird, backwards kind of way!)
...[
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
'process.env.POSTGRAPHILE_ENV': '"production"',
'process.env.NODE_PG_FORCE_NATIVE': JSON.stringify('1'),
...(postgraphileOptions.graphiql
? null
: {
'process.env.POSTGRAPHILE_OMIT_ASSETS': '"1"',
}),
}),
new webpack.NormalModuleReplacementPlugin(/pg\/lib\/native\/index\.js$/, '../client.js'),
],
// Omit websocket functionality from postgraphile:
new webpack.NormalModuleReplacementPlugin(
/postgraphile\/build\/postgraphile\/http\/subscriptions\.js$/,
`${__dirname}/src/postgraphile-http-subscriptions.js`
),
// Just in case you install express:
new webpack.NormalModuleReplacementPlugin(
/express\/lib\/view\.js$/,
`${__dirname}/src/express-lib-view.js`
),
],
node: {
__dirname: false, // just output `__dirname`
},
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
// Without this, you may get errors such as
// `Error: GraphQL conflict for 'e' detected! Multiple versions of graphql exist in your node_modules?`
mangle: false,
},
}),
],
},
};