forked from reduxjs/redux-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tsdx.config.js
59 lines (53 loc) · 1.46 KB
/
tsdx.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
const { join } = require('path')
const stripCode = require('rollup-plugin-strip-code')
const pkg = require('./package.json')
module.exports = {
rollup(config, options) {
config.output.name = 'RTK'
const { env, format } = options
// eslint-disable-next-line default-case
switch (format) {
case 'system':
delete config.external
config.input = 'src/index.ts'
config.output = {
file: 'dist/redux-toolkit.esm.production.mjs',
format: 'es',
indent: false
}
if (env === 'production') {
config.plugins.unshift([
stripCode({
start_comment: 'PROD_START_REMOVE_UMD',
end_comment: 'PROD_STOP_REMOVE_UMD'
})
])
} else {
config.output.file = config.output.file.replace(
'production',
'development'
)
}
break
case 'umd':
delete config.external
config.output.indent = false
if (env === 'production') {
config.plugins.unshift(
stripCode({
start_comment: 'PROD_START_REMOVE_UMD',
end_comment: 'PROD_STOP_REMOVE_UMD'
})
)
config.output.file = join(__dirname, pkg.unpkg)
} else {
config.output.file = config.output.file.replace(
'umd.development',
'umd'
)
}
break
}
return config
}
}