forked from fergiemcdowall/search-index
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
76 lines (74 loc) · 1.85 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const path = require('path')
const webpack = require('webpack')
const glob = require('glob')
const pkg = require('./package.json')
const config = {
plugins: [
// deal with the funky invokation of p-queue using "await import"
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
}),
// Webpack 5 no longer polyfills 'process'
new webpack.ProvidePlugin({
process: 'process/browser'
}),
// as per https://github.com/webpack/changelog-v5/issues/10
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
})
],
target: ['web'],
resolve: {
fallback: {
// BREAKING CHANGE: webpack < 5 used to include polyfills for
// node.js core modules by default. This is no longer the
// case.
assert: false,
buffer: require.resolve('buffer/'),
fs: false,
path: require.resolve('path-browserify'),
stream: require.resolve('stream-browserify'),
util: false,
os: require.resolve('os-browserify')
}
}
}
module.exports = [
{
...config,
mode: 'production',
entry: './src/main.js',
output: {
path: path.resolve('dist'),
filename: 'search-index-' + pkg.version + '.js',
library: 'SearchIndex'
}
},
{
...config,
mode: 'production',
entry: './src/main.js',
experiments: {
outputModule: true
},
output: {
path: path.resolve('dist'),
filename: 'search-index-esm-' + pkg.version + '.js',
library: {
type: 'module'
}
}
},
{
...config,
// Use "mode: 'production" to keep bundle size low(ish- around 3mb)
// possibly it would be good to have some kind of code splitting
// instead
mode: 'production',
entry: glob.sync('./test/src/*-test.js'),
output: {
path: path.resolve('test/sandbox'),
filename: 'browser-tests.js'
}
}
]