-
Notifications
You must be signed in to change notification settings - Fork 32
/
vite.config.ts
92 lines (86 loc) · 3.11 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import dts from "vite-plugin-dts";
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 Bulma Theme v${version} | MIT License | github.com/oruga-ui/theme-bulma */`;
}
// 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,
minify: "terser",
lib: {
entry: resolve(__dirname, "src/plugins/theme.ts"),
name: "OrugaThemeBulma",
fileName: "bulma",
formats: ["es", "cjs", "umd"],
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ["vue", /oruga\/.*/],
output: {
assetFileNames: "bulma.[ext]",
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
vue: "Vue",
},
},
},
},
css: {
// rename default `style.css` to `bulma.css`
postcss: { to: "bulma.css" },
preprocessorOptions: {
includePaths: ["node_modules"],
scss: {
// this can be removed with bulma update (https://github.com/jgthms/bulma/issues/3907)
silenceDeprecations: [
"mixed-decls",
"color-functions",
"global-builtin",
"import",
"legacy-js-api",
],
},
},
},
plugins: [
// build types in dist/types
dts({
outDir: "./dist/types",
include: ["src/plugins/theme.ts"],
}),
// copy assets into dist
copy({
targets: [{ src: "src/assets/scss", dest: "." }],
}),
// adds a banner to every generated dist file
banner(generate(pkg.version)),
],
};
}
});