forked from fancyapps/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
75 lines (66 loc) · 1.94 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
66
67
68
69
70
71
72
73
74
75
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import babel from "rollup-plugin-babel";
import { eslint } from "rollup-plugin-eslint";
import { terser } from "rollup-plugin-terser";
import banner from "rollup-plugin-banner";
import filesize from "rollup-plugin-filesize";
import pkg from "./package.json";
const config = [];
const files = ["Panzoom", "Panzoom.Controls", "Carousel", "Carousel.Autoplay", "Fancybox"];
for (const file_name of files) {
let input_file;
let output_file;
const parts = file_name.split(".");
const component = parts[0];
const plugin = parts[1] || false;
if (plugin) {
input_file = `${component}/plugins/${plugin}/${plugin}.js`;
output_file = `${component.toLowerCase()}.${plugin.toLowerCase()}`;
} else {
input_file = `${component}/index.js`;
output_file = component.toLowerCase();
}
config.push({
input: `src/${input_file}`,
output: {
file: `dist/${output_file}.esm.js`,
format: "es",
exports: "named",
},
plugins: [
eslint(),
replace({ __VERSION__: pkg.version, preventAssignment: true }),
terser(),
banner(`@fancyapps/ui/${file_name} v${pkg.version}`),
filesize({ showMinifiedSize: false }),
],
});
config.push({
input: `src/${input_file}`,
output: {
file: `dist/${output_file}.umd.js`,
format: "umd",
name: "window",
esModule: false,
extend: true,
exports: "named",
},
plugins: [
babel({
babelrc: false,
exclude: "node_modules/**",
presets: [["@babel/preset-env"]],
}),
resolve(),
commonjs(),
eslint(),
replace({ __VERSION__: pkg.version, preventAssignment: true }),
terser(),
banner(`@fancyapps/ui/${file_name} v${pkg.version}`),
filesize({ showMinifiedSize: false }),
],
});
}
export default config;