LiveAtlas/vite.config.ts

49 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

2021-05-27 13:25:33 +00:00
// noinspection JSUnusedGlobalSymbols
2021-09-10 14:32:48 +00:00
import {defineConfig, loadEnv} from 'vite';
2021-05-15 19:25:03 +00:00
import { resolve } from 'path';
import vue from '@vitejs/plugin-vue';
2021-05-24 15:43:13 +00:00
import svgSpritePlugin from "vite-plugin-svg-sprite-component";
import analyze from 'rollup-plugin-analyzer';
2022-06-18 20:12:54 +00:00
import { splitVendorChunkPlugin } from 'vite'
2021-05-15 19:25:03 +00:00
2021-09-10 14:32:48 +00:00
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd())
// expose .env as process.env instead of import.meta since jest does not import meta yet
const envWithProcessPrefix = Object.entries(env).reduce(
(prev, [key, val]) => {
return {
...prev,
['process.env.' + key]: `"${val}"`,
2021-05-15 19:25:03 +00:00
}
2021-09-10 14:32:48 +00:00
},
{},
);
return {
2022-06-18 20:12:54 +00:00
plugins: [splitVendorChunkPlugin(), vue(), analyze(), svgSpritePlugin({
2021-09-10 14:32:48 +00:00
symbolId: (name) => `icon--${name}`,
2022-01-13 20:09:04 +00:00
removeAttrs: ['xmlns', 'width', 'height', 'version']
2021-09-10 14:32:48 +00:00
})],
base: './',
server: {
host: '0.0.0.0',
port: 8080
},
resolve: {
alias: [
{
find: '@',
replacement: resolve(__dirname, 'src')
}
]
},
build: {
chunkSizeWarningLimit: 600,
assetsDir: 'live-atlas/assets'
},
define: envWithProcessPrefix,
2021-05-15 19:25:03 +00:00
}
2021-08-27 01:02:16 +00:00
});