-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrollup.config.js
83 lines (80 loc) · 2.99 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import merge from "deepmerge";
import { createBasicConfig } from "@open-wc/building-rollup";
import html from "rollup-plugin-bundle-html-thomzz";
import copy from "rollup-plugin-copy";
import execute from "rollup-plugin-execute";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import { readFileSync } from "fs";
const baseConfig = createBasicConfig();
export default merge(baseConfig, {
input: "./build/src/index.js",
output: {
dir: "build",
format: "cjs",
sourcemap: true,
},
plugins: [
nodeResolve(),
copy({
targets: [
{
src: "src/manifest.json",
dest: "dist",
transform: (contents) =>
contents
.toString()
.replace(
"__NEBULA_VERSION_NAME__",
JSON.parse(readFileSync("package.json")).version
),
},
{
src: "./node_modules/webextension-polyfill/dist/browser-polyfill.js",
dest: "dist",
},
{
src: "./node_modules/webextension-polyfill/dist/browser-polyfill.js.map",
dest: "dist",
},
{
src: "./node_modules/alpinejs/dist/cdn.js",
dest: "dist",
rename: "alpine.js",
},
{ src: "assets", dest: "dist" },
{
src: "build/src/index.js",
dest: "dist",
rename: "z_index.js", // Needed to ensure that tippy.js and popper are imported first
transform: (contents) =>
contents
.toString()
.replace(
"__NEBULA_VERSION__",
JSON.parse(readFileSync("src/manifest.json"))
.version
)
.replace("// @ts-ignore\n", "")
.replace(
"const SCREENSHOT_MODE = false;",
process.env.SCREENSHOT_MODE === "true"
? "const SCREENSHOT_MODE = true;"
: "const SCREENSHOT_MODE = false;"
),
},
],
hook: "generateBundle",
}),
html({
template: "src/template.html",
dest: "dist",
filename: "index.html",
absolute: true,
}),
execute([
"cpy 'build/src/background.js' dist",
"npx tailwindcss -i ./src/newtab.css -o ./dist/newtab.css",
"npx prettier --tab-width 4 --write dist/**/*.{js,json,html,css}",
]),
],
});