generated from urpflanze-org/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
executable file
·57 lines (52 loc) · 1.49 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
const webpack = require('webpack')
const path = require('path')
const package = require('./package.json')
const version = JSON.stringify(package.version)
const plugins = bProduction => [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(bProduction ? 'production' : 'development'),
}),
new webpack.BannerPlugin({
banner:
`@license Urpflanze Animation v${version}` +
`\n[file]` +
`\n\nGithub: https://github.com/urpflanze-org/animation` +
`\n\nThis source code is licensed under the MIT license found in the\nLICENSE file in the root directory of this source tree.`,
}),
]
const umd = bProduction => ({
entry: {
urpflanze: './dist/cjs/index.js',
},
output: {
filename: bProduction ? 'urpflanze-animation.min.js' : 'urpflanze-animation.js',
path: path.resolve('./build/umd'),
library: {
name: 'Animation',
type: 'umd',
},
globalObject: 'window',
},
plugins: plugins(bProduction),
devtool: bProduction ? undefined : 'source-map',
mode: bProduction ? 'production' : 'none',
})
const esm = bProduction => ({
entry: {
urpflanze: './dist/esm/index.js',
},
output: {
filename: bProduction ? 'urpflanze-animation.min.js' : 'urpflanze-animation.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), umd(true), esm(false), esm(true)]