-
Notifications
You must be signed in to change notification settings - Fork 192
/
rollup.config.mjs
57 lines (55 loc) · 1.59 KB
/
rollup.config.mjs
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
import commonjs from "@rollup/plugin-commonjs";
import { globSync } from "glob";
import path from "node:path";
import copy from "rollup-plugin-copy";
import esbuild from "rollup-plugin-esbuild";
const inputPaths = globSync(["src/jcanvas.ts", "src/jcanvas-*.ts", ""], {
ignore: "src/*.d.ts",
});
export default inputPaths.map((inputPath) => {
const inputFilenameWithoutExtension = path.basename(inputPath, ".ts");
return {
input: [inputPath],
external: ["jquery"],
output: [
{
file: `dist/umd/${inputFilenameWithoutExtension}.min.js`,
format: "umd",
name: `jCanvas_${inputFilenameWithoutExtension}`,
sourcemap: true,
globals: {
jquery: "$",
},
},
{
file: `dist/esm/${inputFilenameWithoutExtension}.min.js`,
format: "esm",
sourcemap: true,
globals: {
jquery: "$",
},
},
],
plugins: [
commonjs(),
esbuild({ minify: true, target: "es2020" }),
copy({
targets: [
{
src: `src/${inputFilenameWithoutExtension}.d.ts`,
dest: ["dist/umd", "dist/esm"],
rename: `${inputFilenameWithoutExtension}.min.d.ts`,
transform: (contents) => {
// Since the main declaration file is getting renamed too, we must
// update the references to it from the plugin declaration files
return String(contents).replace(
/jcanvas\.d\.ts/g,
"jcanvas.min.d.ts"
);
},
},
],
}),
],
};
});