1
This commit is contained in:
49
app/vite.config.js
Normal file
49
app/vite.config.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import { defineConfig } from 'vite';
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
import { resolve, dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
let base = './'
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
base = './app'
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [vue()],
|
||||
root: resolve(__dirname, '.'),
|
||||
base: base,
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
less: {
|
||||
javascriptEnabled: true
|
||||
}
|
||||
}
|
||||
},
|
||||
build: {
|
||||
outDir: resolve(__dirname, './dist'),
|
||||
emptyOutDir: true,
|
||||
rollupOptions: {
|
||||
input: resolve(__dirname, 'index.html')
|
||||
},
|
||||
assetsDir: 'assets',
|
||||
chunkSizeWarningLimit: 1000,
|
||||
// 对于 Electron,需要确保模块能正确加载
|
||||
modulePreload: false, // 禁用 module preload,避免 file:// 协议问题
|
||||
commonjsOptions: {
|
||||
include: []
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 3000,
|
||||
strictPort: true
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'@': resolve(__dirname, '.')
|
||||
},
|
||||
extensions: ['.js', '.vue', '.json']
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user