-
Notifications
You must be signed in to change notification settings - Fork 59
/
rollup.config.mjs
executable file
·48 lines (46 loc) · 1.6 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
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import livescript from "./lib/rollup-plugin-livescript.js";
import pegjs from "./lib/rollup-plugin-pegjs.mjs";
import terser from "@rollup/plugin-terser";
import { visualizer } from "rollup-plugin-visualizer";
import ignoreInfiniteLoop from "./lib/pegjs-no-infinite-loop.mjs";
const prod = process.env.NODE_ENV === "production"
export default [{
input: "src/index.mjs",
plugins: [
// resolve before pegjs so that the filter in pegjs has less left to do
resolve({extensions: [".js", ".ls"], preferBuiltins: true}),
pegjs({plugins: [ignoreInfiniteLoop], target: "commonjs", exportVar: "parser", format: "bare", trace: false}),
livescript(),
commonjs({ ignoreDynamicRequires: true }),
visualizer({
filename: 'dist/latex.stats.html',
sourcemap: prod,
// template: 'network'
})
],
output: [{
file: "dist/latex.mjs",
format: "es",
sourcemap: prod,
plugins: [...(prod ? [terser()] : [])]
}, {
file: "dist/latex.js",
format: "umd",
name: "latexjs",
sourcemap: prod,
plugins: [
{
name: 'import-meta-to-umd',
resolveImportMeta(property) {
if (property === 'url') {
return `document.currentScript && document.currentScript.src`;
}
return null;
}
},
...(prod ? [terser()] : [])
]
}]
}]