Files
OpenDTU/webapp/vite.config.ts

81 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-10-17 19:18:45 +02:00
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import viteCompression from 'vite-plugin-compression';
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
2022-10-17 19:18:45 +02:00
2023-11-16 18:13:46 +01:00
import path from 'path'
// example 'vite.user.ts': export const proxy_target = '192.168.16.107'
let proxy_target;
try {
2024-04-12 20:34:30 +02:00
// eslint-disable-next-line
proxy_target = require('./vite.user.ts').proxy_target;
} catch (error) {
2023-08-09 18:23:50 +02:00
proxy_target = '192.168.20.110';
}
2022-10-17 19:18:45 +02:00
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
viteCompression({ deleteOriginFile: true, threshold: 0 }),
cssInjectedByJsPlugin(),
VueI18nPlugin({
/* options */
2023-03-14 18:29:21 +01:00
include: path.resolve(path.dirname(fileURLToPath(import.meta.url)), './src/locales/**.json'),
fullInstall: false,
forceStringify: true,
2023-03-23 23:37:58 +01:00
strictMessage: false,
2024-03-12 16:42:29 +01:00
jitCompilation: false,
}),
],
2022-10-17 19:18:45 +02:00
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'~bootstrap': path.resolve(__dirname, 'node_modules/bootstrap'),
2022-10-17 19:18:45 +02:00
}
},
build: {
// Prevent vendor.css being created
cssCodeSplit: false,
outDir: '../webapp_dist',
emptyOutDir: true,
minify: 'terser',
chunkSizeWarningLimit: 1024,
2022-10-17 19:18:45 +02:00
rollupOptions: {
output: {
// Only create one js file
inlineDynamicImports: true,
// Get rid of hash on js file
entryFileNames: 'js/app.js',
// Get rid of hash on css file
assetFileNames: "assets/[name].[ext]",
},
},
},
esbuild: {
drop: ['console', 'debugger'],
},
2022-10-17 19:18:45 +02:00
server: {
proxy: {
'^/api': {
target: 'http://' + proxy_target
2022-10-17 19:18:45 +02:00
},
'^/livedata': {
target: 'ws://' + proxy_target,
2022-10-17 19:18:45 +02:00
ws: true,
changeOrigin: true
2022-12-19 21:03:09 +01:00
},
'^/console': {
target: 'ws://' + proxy_target,
2022-12-19 21:03:09 +01:00
ws: true,
changeOrigin: true
2022-10-17 19:18:45 +02:00
}
}
}
})