2022-08-16 15:30:23 +00:00
|
|
|
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';
|
2022-09-01 11:02:33 +00:00
|
|
|
import MonacoEditorPlugin from 'vite-plugin-monaco-editor';
|
2022-08-16 15:30:23 +00:00
|
|
|
|
2023-01-12 03:45:01 +00:00
|
|
|
import AutoImport from 'unplugin-auto-import/vite';
|
|
|
|
import Components from 'unplugin-vue-components/vite';
|
|
|
|
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';
|
|
|
|
|
2022-08-16 15:30:23 +00:00
|
|
|
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': {
|
2023-02-03 02:28:16 +00:00
|
|
|
target: 'http://127.0.0.1:9999/',
|
2022-08-16 15:30:23 +00:00
|
|
|
changeOrigin: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
vue(),
|
|
|
|
DefineOptions(),
|
2022-08-19 08:02:58 +00:00
|
|
|
eslintPlugin({
|
|
|
|
exclude: ['**/*.js'],
|
|
|
|
}),
|
2022-08-16 15:30:23 +00:00
|
|
|
vueJsx(),
|
|
|
|
VueSetupExtend(),
|
2022-08-19 08:02:58 +00:00
|
|
|
|
2022-09-01 11:02:33 +00:00
|
|
|
MonacoEditorPlugin({}),
|
2022-08-16 15:30:23 +00:00
|
|
|
viteEnv.VITE_REPORT && visualizer(),
|
|
|
|
viteEnv.VITE_BUILD_GZIP &&
|
|
|
|
viteCompression({
|
|
|
|
verbose: true,
|
|
|
|
disable: false,
|
|
|
|
threshold: 10240,
|
|
|
|
algorithm: 'gzip',
|
|
|
|
ext: '.gz',
|
|
|
|
}),
|
2023-01-12 03:45:01 +00:00
|
|
|
AutoImport({
|
|
|
|
resolvers: [
|
|
|
|
ElementPlusResolver({
|
|
|
|
importStyle: 'sass',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
|
|
|
Components({
|
|
|
|
resolvers: [
|
|
|
|
ElementPlusResolver({
|
|
|
|
importStyle: 'sass',
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
}),
|
2022-08-16 15:30:23 +00:00
|
|
|
],
|
|
|
|
esbuild: {
|
|
|
|
pure: viteEnv.VITE_DROP_CONSOLE ? ['console.log', 'debugger'] : [],
|
|
|
|
},
|
|
|
|
build: {
|
2022-10-17 08:32:31 +00:00
|
|
|
outDir: '../cmd/server/web',
|
2022-08-16 15:30:23 +00:00
|
|
|
minify: 'esbuild',
|
|
|
|
rollupOptions: {
|
|
|
|
output: {
|
|
|
|
chunkFileNames: 'assets/js/[name]-[hash].js',
|
|
|
|
entryFileNames: 'assets/js/[name]-[hash].js',
|
|
|
|
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
});
|