forked from Automattic/mongoose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
59 lines (55 loc) · 1.3 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
58
'use strict';
const webpack = require('webpack');
const paths = require('path');
const webpackConfig = {
entry: require.resolve('./browser.js'),
output: {
filename: './dist/browser.umd.js',
path: paths.resolve(__dirname, ''),
library: 'mongoose',
libraryTarget: 'umd',
// override default 'window' globalObject so browser build will work in SSR environments
// may become unnecessary in webpack 5
globalObject: 'typeof self !== \'undefined\' ? self : this'
},
externals: [
/^node_modules\/.+$/
],
module: {
rules: [
{
test: /\.js$/,
include: [
/\/mongoose\//i,
/\/kareem\//i
],
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
]
},
resolve: {
alias: {
'bn.js': require.resolve('bn.js')
},
fallback: {
assert: require.resolve('assert-browserify'),
buffer: require.resolve('buffer'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify')
}
},
target: 'web',
mode: 'production',
plugins: [
new webpack.DefinePlugin({
process: '({env:{}})'
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
})
]
};
module.exports = webpackConfig;