You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
65 lines
1.5 KiB
65 lines
1.5 KiB
import { defineConfig } from "vite"
|
|
import reactRefresh from "@vitejs/plugin-react-refresh"
|
|
// import WindiCSS from "vite-plugin-windicss"
|
|
const { resolve, join } = require("path")
|
|
import electron from "vitejs-plugin-electron"
|
|
import { minifyHtml, injectHtml } from "vite-plugin-html"
|
|
import replace from '@rollup/plugin-replace';
|
|
|
|
|
|
let isDev = process.env.NODE_ENV === "development"
|
|
|
|
let plugins = []
|
|
let staticPath = isDev? '/static': 'static'
|
|
plugins.push(
|
|
replace({
|
|
preventAssignment: true,
|
|
"__static": staticPath,
|
|
"__staticVar": `"${staticPath}"`
|
|
})
|
|
)
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
root: resolve(__dirname, "src/render"),
|
|
base: "./",
|
|
publicDir: resolve(__dirname, "resource/electron"),
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
additionalData: `@import "@/assets/style/global.scss";`,
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: +process.env.PORT,
|
|
},
|
|
build: {
|
|
outDir: resolve(__dirname, "dist/electron"),
|
|
emptyOutDir: true,
|
|
minify: false,
|
|
commonjsOptions: {},
|
|
assetsDir: "", // 相对路径 加载问题
|
|
sourcemap: true,
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
"@": join(__dirname, "src/render"),
|
|
"@render": join(__dirname, "src/render"),
|
|
"@main": join(__dirname, "src/main"),
|
|
"@src": join(__dirname, "src"),
|
|
"@root": __dirname,
|
|
},
|
|
},
|
|
//
|
|
plugins: [
|
|
...plugins,
|
|
reactRefresh(),
|
|
minifyHtml(),
|
|
injectHtml({
|
|
injectData: {
|
|
title: "代码片段管理工具"
|
|
},
|
|
}),
|
|
],
|
|
})
|
|
|