-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
68 lines (66 loc) · 2 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
/* eslint-disable unicorn/no-await-expression-member */
import { defineConfig } from "rollup";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import svelte from "rollup-plugin-svelte";
import postcss from "rollup-plugin-postcss";
import prettier from "rollup-plugin-prettier";
import metablock from "rollup-plugin-userscript-metablock";
import svelteConfig from "./svelte.config";
import package_ from "./package.json";
const isDevelopment = process.env.NODE_ENV === "development";
console.log(`isDevelopment: ${isDevelopment}`);
export default (async () =>
defineConfig({
input: "src/main.ts",
output: {
file: "dist/yacu.userscript.js",
/**
* 不要在 main.ts 里导出
* 这样设置只是因为没有必要创建 IIFE
*/
format: "esm",
},
plugins: [
nodeResolve(),
commonjs(),
svelte(svelteConfig),
postcss(),
...(isDevelopment
? [
(await import("rollup-plugin-esbuild")).default({
minify: false,
target: "esnext",
}),
]
: [
(await import("@rollup/plugin-typescript")).default(),
(await import("@rollup/plugin-babel")).babel({
babelHelpers: "bundled",
exclude: "node_modules/**",
extensions: [
".js",
".jsx",
".es6",
".es",
".mjs",
".ts",
".tsx",
".svelte",
],
}),
(await import("rollup-plugin-terser")).terser({ mangle: false }),
]),
prettier({ parser: "babel" }),
metablock({
file: "src/meta.json",
override: {
version: package_.version,
description: package_.description,
homepage: package_.homepage,
author: package_.author,
license: package_.license,
},
}),
],
}))();