forked from contentful/contentful-sdk-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
69 lines (65 loc) · 1.49 KB
/
rollup.config.mjs
File metadata and controls
69 lines (65 loc) · 1.49 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
65
66
67
68
69
import pkg from './package.json' with { type: 'json' }
import nodeResolve from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
import replace from '@rollup/plugin-replace'
import typescript from '@rollup/plugin-typescript'
import sourcemaps from 'rollup-plugin-sourcemaps2'
const baseConfig = {
input: 'src/index.ts',
plugins: [
nodeResolve(),
typescript({
tsconfig: './tsconfig.json',
declaration: false,
noEmitOnError: true,
}),
sourcemaps(),
replace({
preventAssignment: true,
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
__VERSION__: JSON.stringify(pkg.version),
}),
json(),
],
external: [/node_modules\/(?!tslib.*)/],
}
const typesConfig = {
...baseConfig,
output: {
dir: './dist/types',
format: 'esm',
preserveModules: true,
sourcemap: true,
},
plugins: [
...baseConfig.plugins,
typescript({
tsconfig: './tsconfig.json',
outDir: './dist/types',
declaration: true,
noEmitOnError: true,
emitDeclarationOnly: true,
}),
],
}
const esmConfig = {
...baseConfig,
output: {
dir: './dist',
format: 'esm',
preserveModules: true,
sourcemap: true,
entryFileNames: '[name].js',
chunkFileNames: '[name].js',
},
}
const cjsBundleConfig = {
...baseConfig,
output: {
file: 'dist/cjs/index.cjs',
format: 'cjs',
sourcemap: true,
interop: 'auto',
},
}
export default [esmConfig, typesConfig, cjsBundleConfig]