forked from InsightSoftwareConsortium/itk-wasm
/
webpack.config.cjs
78 lines (73 loc) · 1.49 KB
/
webpack.config.cjs
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
77
78
const path = require('path')
const webpack = require('webpack')
const entry = path.join(__dirname, 'dist', 'browser', 'index.js')
const outputPath = path.join(__dirname, 'dist', 'umd')
const packageJSON = require('./package.json')
const cdnPath = 'https://cdn.jsdelivr.net/npm/'
// const cdnPath = `https://unpkg.com/'
const cdnConfig = path.resolve(__dirname, 'src', 'itkConfigCDN.js')
const library = {
type: 'umd',
name: 'itk'
}
const moduleConfig = {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: { presets: ['@babel/preset-env'] }
}
}
]
}
const resolve = {
modules: [path.resolve(__dirname, 'node_modules')],
fallback: { fs: false, path: false, url: false, module: false },
alias: {
'../itkConfig.js': cdnConfig,
'../../itkConfig.js': cdnConfig
}
}
const performance = {
maxAssetSize: 10000000
}
const plugins = [
new webpack.DefinePlugin({
__itk_version__: JSON.stringify(packageJSON.version)
})
]
const stats = 'errors-only'
module.exports = [{
name: 'development',
mode: 'development',
stats,
entry,
output: {
path: outputPath,
filename: 'itk-wasm.js',
publicPath: cdnPath,
library
},
module: moduleConfig,
resolve,
plugins,
performance
},
{
name: 'production',
mode: 'production',
stats,
entry,
output: {
path: outputPath,
filename: 'itk-wasm.min.js',
publicPath: cdnPath,
library
},
module: moduleConfig,
resolve,
plugins,
performance
}
]