mirror of https://github.com/1Panel-dev/1Panel
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.
79 lines
2.5 KiB
79 lines
2.5 KiB
import { defineConfig, loadEnv, ConfigEnv, UserConfig } from 'vite';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import { resolve } from 'path';
|
|
import { wrapperEnv } from './src/utils/get-env';
|
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
import viteCompression from 'vite-plugin-compression';
|
|
import VueSetupExtend from 'vite-plugin-vue-setup-extend';
|
|
import eslintPlugin from 'vite-plugin-eslint';
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
import DefineOptions from 'unplugin-vue-define-options/vite';
|
|
import MonacoEditorPlugin from 'vite-plugin-monaco-editor';
|
|
|
|
export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
|
|
const env = loadEnv(mode, process.cwd());
|
|
const viteEnv = wrapperEnv(env);
|
|
|
|
return {
|
|
resolve: {
|
|
alias: {
|
|
'@': resolve(__dirname, './src'),
|
|
'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
|
|
},
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
scss: {
|
|
additionalData: `@use "@/styles/var.scss" as *;`,
|
|
},
|
|
},
|
|
},
|
|
server: {
|
|
port: viteEnv.VITE_PORT,
|
|
open: viteEnv.VITE_OPEN,
|
|
proxy: {
|
|
'/api/v1': {
|
|
target: 'http://127.0.0.1:9999',
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
plugins: [
|
|
vue(),
|
|
DefineOptions(),
|
|
eslintPlugin({
|
|
exclude: ['**/*.js'],
|
|
}),
|
|
vueJsx(),
|
|
VueSetupExtend(),
|
|
|
|
MonacoEditorPlugin({}),
|
|
viteEnv.VITE_REPORT && visualizer(),
|
|
// * gzip compress
|
|
viteEnv.VITE_BUILD_GZIP &&
|
|
viteCompression({
|
|
verbose: true,
|
|
disable: false,
|
|
threshold: 10240,
|
|
algorithm: 'gzip',
|
|
ext: '.gz',
|
|
}),
|
|
],
|
|
esbuild: {
|
|
pure: viteEnv.VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [],
|
|
},
|
|
build: {
|
|
outDir: '../cmd/server/web',
|
|
minify: 'esbuild',
|
|
rollupOptions: {
|
|
output: {
|
|
// Static resource classification and packaging
|
|
chunkFileNames: 'assets/js/[name]-[hash].js',
|
|
entryFileNames: 'assets/js/[name]-[hash].js',
|
|
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|