forked from digirati-co-uk/vam-viewer
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.umd.js
47 lines (42 loc) · 1.19 KB
/
webpack.umd.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
const path = require('path');
const baseConfig = require('@fesk/scripts/webpack');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const MetalsmithWebpackPlugin = require('@fesk/plugin-metalsmith');
const fullName = '@digirati/vam-viewer';
const packageName = 'VAMViewer';
const plugins = baseConfig.plugins
.map(plugin => {
if (plugin instanceof MetalsmithWebpackPlugin) {
return null;
}
if (plugin instanceof CleanWebpackPlugin) {
return new CleanWebpackPlugin({
...plugin.options,
cleanOnceBeforeBuildPatterns: ['umd'],
});
}
return plugin;
})
.filter(Boolean);
const config = Object.assign({}, baseConfig, {
output: {
path: path.resolve(process.cwd(), 'dist', 'umd'),
filename: `${fullName}.js`,
libraryTarget: 'umd',
library: packageName,
umdNamedDefine: true,
chunkFilename: '[name].bundle.js',
globalObject: 'this',
},
plugins,
externals: baseConfig.externals,
});
config.externals = {
'node-fetch': 'fetch',
'fetch-cookie/node-fetch': 'fetch',
react: 'React',
'react-dom': 'ReactDOM',
'react-reconciler': 'react-reconciler',
openseadragon: 'OpenSeadragon',
};
module.exports = config;