-
Notifications
You must be signed in to change notification settings - Fork 7
/
rollup.config.js
68 lines (66 loc) · 1.93 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
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import babel from "@rollup/plugin-babel";
import image from "@rollup/plugin-image";
import inject from "@rollup/plugin-inject";
import amd from "rollup-plugin-amd";
import { terser } from "rollup-plugin-terser";
import visualizer from "rollup-plugin-visualizer";
import pkg from "./package.json";
const globals = {
jquery: "$",
moment: "moment"
};
export default [
{
input: "src/main.js",
external: ["jquery", "moment", "jquery-ui-bundle"],
// UMD builds, suitable for use in any environment (including the browser, as a `<script>` tag)
output: [
{
name: "mizar",
file: "dist/mizar.min.js",
format: "umd",
globals,
// Minify bundle using terser
plugins: [terser()]
},
// Readable UMD build
{
name: "mizar",
file: "dist/mizar.js",
format: "umd",
globals
},
// an ES module bundle, suitable for use in other people's libraries and applications
{
file: pkg.module,
format: "es",
globals
}
],
plugins: [
resolve(),
commonjs(),
// Resolving jquery-ui as amd modules throws an error
amd({ exclude: ["node_modules/jquery-ui/**"] }),
// Babel config
babel({
babelHelpers: "bundled",
babelrc: false,
exclude: ["node_modules/**"],
// See https://github.com/browserslist/browserslist/
presets: [["@babel/preset-env", { targets: { browsers: ["> 5%", "Firefox ESR"] }, modules: false }]]
}),
// Solve JQuery errors when importing the library
inject({
$: "jquery",
jQuery: "jquery"
}),
// Allow image importing as base64, use it for convenience but it is not optimal
image(),
// Generates a stats.html file at the root to analyze the bundle
visualizer()
]
}
];