forked from flatpickr/flatpickr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.ts
50 lines (45 loc) · 1.33 KB
/
rollup.ts
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
import typescript from "rollup-plugin-typescript";
import babel from "rollup-plugin-babel";
import serve from "rollup-plugin-serve";
import livereload from "rollup-plugin-livereload";
import { resolve } from "path";
import * as pkg from "../package.json";
import { RollupOptions } from "rollup";
export const getConfig = (opts?: { dev: boolean }): RollupOptions => ({
input: "./src/index.ts",
output: {
file: "dist/flatpickr.js",
name: "flatpickr",
format: "umd",
exports: "default",
banner: `/* flatpickr v${pkg.version}, @license MIT */`,
...(opts && opts.dev ? { sourcemap: true } : {}),
},
onwarn(warning) {
const ignoredCircular = ["src/types/options.ts", "src/utils/dates.ts"];
if (typeof warning === "string") throw Error(warning);
else if (
warning.code !== "CIRCULAR_DEPENDENCY" ||
!warning.importer ||
!ignoredCircular.includes(warning.importer!)
) {
throw Error(warning.message);
}
},
plugins: [
typescript({ tsconfig: resolve("./src/tsconfig.json", __dirname) }),
babel({ runtimeHelpers: true }),
...(opts && opts.dev
? [
serve({
open: true,
contentBase: "",
host: "127.0.0.1",
port: 8000,
}),
livereload(),
]
: []),
],
});
export default getConfig();