-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvite.config.ts
64 lines (58 loc) · 1.61 KB
/
vite.config.ts
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
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import banner from "vite-plugin-banner";
import { viteStaticCopy as copy } from "vite-plugin-static-copy";
import { fileURLToPath } from "url";
import { resolve } from "path";
import pkg from "./package.json" with { type: "json" };
function generate(version: string): string {
const preview_build = process.env.ORUGA_PREVIEW_BUILD;
if (preview_build) {
version = `${version} (build ${preview_build})`;
}
return `/*! Oruga Default Theme v${version} | MIT License | github.com/oruga-ui/theme-oruga */`;
}
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
if (mode === "development") {
return {
root: __dirname,
plugins: [vue()],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
};
} else {
return {
build: {
emptyOutDir: true,
copyPublicDir: false,
lib: {
entry: resolve(__dirname, "src/plugins/theme.ts"),
name: "OrugaDefaultTheme",
fileName: "theme",
formats: ["es"],
},
rollupOptions: {
output: {
assetFileNames: "oruga.[ext]",
},
},
},
css: {
// rename default `style.css` to `oruga.css`
postcss: { to: "oruga.css" },
},
plugins: [
// copy assets into dist
copy({
targets: [{ src: "src/assets/scss", dest: "." }],
}),
// adds a banner to every generated dist file
banner(generate(pkg.version)),
],
};
}
});