-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
64 lines (62 loc) · 1.91 KB
/
rollup.config.js
File metadata and controls
64 lines (62 loc) · 1.91 KB
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
import typescript from '@rollup/plugin-typescript';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import replace from '@rollup/plugin-replace';
const createConfig = (input, output, format, options = {}) => ({
input,
output: {
file: output,
format,
sourcemap: !options.minify,
exports: 'named',
inlineDynamicImports: true,
...(options.name && { name: options.name }),
...(options.globals && { globals: options.globals })
},
plugins: [
replace({
preventAssignment: true,
values: {
'process.env.npm_package_version': JSON.stringify(process.env.npm_package_version)
}
}),
nodeResolve({ preferBuiltins: false }),
typescript({
tsconfig: './tsconfig.build.json',
target: 'ES2020',
module: 'ESNext',
declaration: !options.minify,
declarationMap: !options.minify,
sourceMap: !options.minify,
inlineSources: !options.minify,
outDir: 'dist'
}),
...(options.minify ? [terser({
compress: {
drop_console: false,
drop_debugger: true
},
format: {
comments: false
}
})] : [])
],
external: options.bundleAll ? [] : ['axios', 'superagent']
});
export default [
createConfig('src/index.ts', 'dist/index.cjs', 'cjs'),
createConfig('src/index.ts', 'dist/index.esm.js', 'es'),
createConfig('src/http/integrations/axios.ts', 'dist/axios.cjs', 'cjs'),
createConfig('src/http/integrations/axios.ts', 'dist/axios.esm.js', 'es'),
createConfig('src/http/integrations/superagent.ts', 'dist/superagent.cjs', 'cjs'),
createConfig('src/http/integrations/superagent.ts', 'dist/superagent.esm.js', 'es'),
createConfig('src/index.ts', 'dist/index.umd.min.js', 'umd', {
name: 'MastercardOAuth2Client',
minify: true,
bundleAll: false,
globals: {
'axios': 'axios',
'superagent': 'superagent'
}
})
];