-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.build.ts
77 lines (70 loc) · 1.94 KB
/
vite.config.build.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
import { defineConfig } from "vite";
const path = require("path");
const atImport = require("postcss-import");
const config = require("./package.json");
const banner = `/*!
* ${config.name} v${config.version} ${new Date()}
* (c) 2023 @BlazorMix
* Released under the MIT License.
*/`;
const { resolve } = path;
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
var isProd = mode === "production";
console.log("isProd", isProd)
return {
resolve: {
alias: [
{ find: "@", replacement: resolve(__dirname, "./src/BlazorMix/wwwroot/src/scss") },
],
},
esbuild: {
drop: isProd ? ["console", "debugger"] : [],
},
css: {
preprocessorOptions: {
scss: {
charset: false,
additionalData: `@import "@/styles/variables.scss";`,
},
postcss: {
plugins: [atImport({ path: path.join(__dirname, "src`") })],
},
},
},
plugins: [],
build: {
sourcemap: !isProd,
emptyOutDir: true,
minify: true,
outDir: "./src/BlazorMix/wwwroot/dist",
rollupOptions: {
output: {
banner,
assetFileNames: (fileInfo) => {
// console.log("fileInfo", fileInfo);
// if (fileInfo.name == "style.css") {
// return "index.min.css";
// }
return `[name].[ext]`;
},
// 入口文件 input 配置所指向的文件包名 默认值:"[name].js"
entryFileNames: (fileInfo) => {
console.log("entryFileNames", fileInfo.facadeModuleId);
return "[name].min.js";
},
},
},
lib: {
entry: {
index: "./src/BlazorMix/wwwroot/src/ts/index.ts",
default:
"./src/BlazorMix/wwwroot/src/scss/styles/themes/default.scss",
},
name: "blazor-mix",
fileName: "blazor-mix",
formats: ["es"],
},
},
};
});