-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.userscript.config.js
39 lines (36 loc) · 975 Bytes
/
rollup.userscript.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
/** Bundle our main script into a valid userscript */
import fs from "fs"
import nodeResolve from "@rollup/plugin-node-resolve"
import serve from "rollup-plugin-serve"
const isProduction = process.env.BUILD === "production"
const isDevelopment = !isProduction
export default {
input: "./src/runtime/userscript/main.js",
output: {
file: "./dist/idmu.user.js",
format: "iife",
sourcemap: "inline"
},
plugins: [
{
buildStart(){
this.addWatchFile("./data/meta.json")
},
banner: () => {
const metadata = JSON.parse(fs.readFileSync("./data/meta.json"))
metadata.version = JSON.parse(fs.readFileSync("./package.json")).version
let str = "// ==UserScript==\n"
for(const property in metadata) {
str += `\n// @${property}\t\t\t\t${metadata[property]}`
}
str += "\n\n// ==/UserScript==\n\n"
return str
}
},
nodeResolve(),
isDevelopment && serve({
contentBase: "dist",
port: process.env.PORT || 3000
}),
]
}