-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.mjs
72 lines (68 loc) · 1.72 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//@ts-check
import { globSync } from "glob";
import vue from "@vitejs/plugin-vue";
import replace from "@rollup/plugin-replace";
import { minify } from "rollup-plugin-esbuild";
import postcss from "rollup-plugin-postcss";
import alias from "@rollup/plugin-alias";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import postcssConfig from "./postcss.config.mjs";
import path from "node:path";
const entrypoints = globSync("*/**/**/*.component.js", {
ignore: [
"dist/**",
"src/components/elections-vote/elections-vote.component.js",
"src/components/elections-nominate/elections-nominate.component.js",
],
});
function inlineCSSPlugin() {
return {
name: "inline-css",
resolveId(source, importer) {
if (source.includes("?inline")) {
// return source.replace('?inline', '');
const importerDir = path.dirname(importer);
const cssPath = source.split("?")[0]; // Remove ?inline part
return path.resolve(importerDir, cssPath);
}
return null;
},
load() {
return null;
},
};
}
/** @type {import("rollup").RollupOptions} */
export default {
input: entrypoints,
output: {
dir: "dist",
format: "es",
},
external: [/^https:\/\//],
plugins: [
replace({
"process.env.NODE_ENV": JSON.stringify(
process.env.NODE_ENV ?? "production",
),
__VUE_OPTIONS_API__: "false",
preventAssignment: true,
}),
alias({
entries: [
{
find: /^vue$/,
replacement:
"https://unpkg.com/vue@3.4.21/dist/vue.runtime.esm-browser.prod.js",
},
],
}),
nodeResolve(),
vue({}),
minify(),
inlineCSSPlugin(),
postcss({
...postcssConfig,
}),
],
};