musescore-downloader/rollup.config.js

84 lines
2 KiB
JavaScript
Raw Normal View History

2019-11-03 19:13:06 +00:00
import typescript from "rollup-plugin-typescript"
import resolve from "rollup-plugin-node-resolve"
import commonjs from "rollup-plugin-commonjs"
import builtins from "rollup-plugin-node-builtins"
import nodeGlobals from "rollup-plugin-node-globals"
import json from "@rollup/plugin-json"
2019-11-03 19:13:06 +00:00
import fs from "fs"
2019-11-03 20:01:29 +00:00
const getBannerText = () => {
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf-8"))
const { version } = packageJson
let bannerText = fs.readFileSync("./src/meta.js", "utf-8")
bannerText = bannerText.replace("%VERSION%", version)
return bannerText
}
2019-11-03 19:13:06 +00:00
2019-12-01 21:25:13 +00:00
const plugins = [
typescript({
target: "ES6",
sourceMap: false,
allowJs: true,
lib: [
"ES6",
"dom"
],
}),
resolve({
preferBuiltins: true,
jsnext: true,
extensions: [".js", ".ts"]
}),
commonjs({
extensions: [".js", ".ts"]
}),
json(),
builtins(),
nodeGlobals({
dirname: false,
filename: false,
baseDir: false,
}),
{
/**
* remove tslib license comments
* @param {string} code
* @param {string} id
*/
transform(code, id) {
if (id.includes("tslib")) {
code = code.split(/\r?\n/g).slice(15).join("\n")
}
return {
code
}
2019-12-01 21:25:13 +00:00
}
},
]
export default [
{
input: "src/worker.ts",
output: {
file: "dist/cache/worker.js",
format: "iife",
2019-12-01 21:45:38 +00:00
banner: "export const PDFWorker = function () { ",
2020-04-28 06:46:21 +00:00
footer: "}\n",
2019-12-01 21:25:13 +00:00
sourcemap: false,
},
2019-12-01 21:25:13 +00:00
plugins,
},
{
2019-12-01 21:45:38 +00:00
input: "src/main.ts",
2019-12-01 21:25:13 +00:00
output: {
file: "dist/main.js",
format: "iife",
sourcemap: false,
banner: getBannerText,
2020-04-28 06:46:21 +00:00
intro: "// fix for Greasemonkey\nwindow.eval('(' + function () {",
outro: "}.toString() + ')()')"
2019-12-01 21:25:13 +00:00
},
2019-12-01 21:45:38 +00:00
plugins,
2019-12-01 21:25:13 +00:00
},
]