YesPlayMusic/packages/web/vite.config.ts

71 lines
1.6 KiB
TypeScript
Raw Normal View History

2022-04-13 16:17:21 +08:00
/// <reference types="vitest" />
import react from '@vitejs/plugin-react'
import dotenv from 'dotenv'
import path, { join } from 'path'
import { defineConfig } from 'vite'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { visualizer } from 'rollup-plugin-visualizer'
2022-05-12 02:45:43 +08:00
dotenv.config({ path: path.resolve(process.cwd(), '../../.env') })
/**
* @see https://vitejs.dev/config/
*/
export default defineConfig({
mode: process.env.NODE_ENV,
2022-05-12 02:45:43 +08:00
root: './',
plugins: [
react(),
/**
* @see https://github.com/vbenjs/vite-plugin-svg-icons
*/
createSvgIconsPlugin({
2022-05-12 02:45:43 +08:00
iconDirs: [join(__dirname, './assets/icons')],
symbolId: 'icon-[name]',
}),
],
base: '/',
build: {
2022-04-02 02:12:15 +08:00
target: process.env.IS_ELECTRON ? 'esnext' : 'modules',
2022-05-12 17:53:04 +08:00
sourcemap: true,
2022-05-12 02:45:43 +08:00
outDir: './dist',
emptyOutDir: true,
rollupOptions: {
plugins: [
visualizer({
2022-05-12 17:53:04 +08:00
filename: './bundle-stats.html',
gzipSize: true,
2022-05-12 17:53:04 +08:00
projectRoot: './',
template: 'treemap',
}),
],
},
},
resolve: {
alias: {
2022-05-12 02:45:43 +08:00
'@': join(__dirname, '../'),
},
},
clearScreen: false,
server: {
2022-05-12 02:45:43 +08:00
port: Number(process.env['ELECTRON_WEB_SERVER_PORT'] || 42710),
proxy: {
'/netease/': {
2022-05-12 02:45:43 +08:00
target: `http://127.0.0.1:${
process.env.ELECTRON_DEV_NETEASE_API_PORT || 3000
}`,
changeOrigin: true,
},
'/yesplaymusic/': {
2022-05-12 02:45:43 +08:00
target: `http://127.0.0.1:${
process.env.ELECTRON_DEV_NETEASE_API_PORT || 3000
}`,
changeOrigin: true,
},
},
},
2022-04-13 16:17:21 +08:00
test: {
environment: 'jsdom',
},
})