This repository was archived by the owner on Oct 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
65 lines (63 loc) · 1.62 KB
/
rollup.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
import dts from "rollup-plugin-dts";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import esbuild from "rollup-plugin-esbuild";
import { terser } from "rollup-plugin-terser";
import json from "@rollup/plugin-json";
export default [{
input: 'src/index.ts',
output: [{
file: 'dist/index.js',
format: 'cjs'
}, {
file: 'dist/index.mjs',
format: 'esm'
}],
plugins: [
{
resolveId(id, importer) {
// console.log(id, importer)
if (id === 'jszip') {
return this.resolve('jszip/dist/jszip.js', importer)
}
if (id === 'gotenberg-js-client') {
return this.resolve('gotenberg-js-client/dist-src/index.js', importer)
}
if (id.startsWith('docx-templates')) {
return this.resolve('./node_modules/docx-templates/src/index.ts', __filename)
}
}
},
{
name: 'replace',
transform(code, id) {
return code.replace(/process\.env\.NODE_ENV/g, '"production"').replace(/process\.nextTick/g, 'undefined');
}
},
json(),
nodeResolve({
preferBuiltins: true,
extensions: ['.mjs', '.js', '.json', '.node']
}),
esbuild({
target: 'es2020'
}),
commonjs(),
terser()
],
external: [
'mime-db'
]
}, {
input: "./dist/index.d.ts",
output: [{ file: "dist/index.d.ts", format: "es" }],
plugins: [{
resolveId(id) {
if (id === 'docx-templates/lib/types') {
return require.resolve('docx-templates/lib/types').split('.')[0] + '.d.ts'
}
}
}, dts({
respectExternal: false
})],
},]