-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
webpack.config.js
67 lines (61 loc) · 1.96 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
const webpack = require('webpack')
const path = require('path')
const package = require('./package.json')
const version = JSON.stringify(package.version)
const dependencies = package.dependencies
const coreVersion = dependencies['@urpflanze/core']
const drawerVersion = dependencies['@urpflanze/drawer-canvas']
const plugins = bProduction => [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(bProduction ? 'production' : 'development'),
}),
new webpack.BannerPlugin({
banner:
`@license UrpflanzeJS v${version}` +
`\n[file]` +
`\n\nGithub: https://github.com/urpflanze-org/urpflanze` +
`\n\nThis source code is licensed under the MIT license found in the\nLICENSE file in the root directory of this source tree.` +
`\n\nCore: ${coreVersion} | DrawerCanvas: ${drawerVersion}`,
}),
]
const umd = (bProduction, bLight) => ({
entry: bLight ? './dist/cjs/index-light.js' : './dist/cjs/index.js',
output: {
filename: 'urpflanze' + (bLight ? '-light' : '') + (bProduction ? '.min' : '') + '.js',
path: path.resolve('./build/umd'),
library: {
name: 'Urpflanze',
type: 'umd',
},
globalObject: 'window',
},
plugins: plugins(bProduction),
devtool: bProduction ? undefined : 'source-map',
mode: bProduction ? 'production' : 'none',
})
const esm = (bProduction, bLight) => ({
entry: bLight ? './dist/esm/index-light.js' : './dist/esm/index.js',
output: {
filename: 'urpflanze' + (bLight ? '-light' : '') + (bProduction ? '.min' : '') + '.js',
path: path.resolve('./build/esm'),
library: {
type: 'module',
},
},
plugins: plugins(bProduction),
devtool: bProduction ? undefined : 'source-map',
mode: bProduction ? 'production' : 'none',
experiments: {
outputModule: true,
},
})
module.exports = [
umd(false, false), // urpflanze.js
umd(true, false), // urpflanze.min.js
umd(false, true), // urpflanze-light.js
umd(true, true), // urpflanze-light.minjs
esm(false, false),
esm(true, false),
esm(false, true),
esm(true, true),
]