yacd/vite.config.ts

40 lines
959 B
TypeScript
Raw Normal View History

2021-05-30 16:33:27 +08:00
import { defineConfig } from 'vite';
import { VitePWA } from 'vite-plugin-pwa';
2022-05-08 18:37:08 +08:00
import react from '@vitejs/plugin-react'
2021-05-30 16:33:27 +08:00
import * as path from 'path';
import * as pkg from './package.json';
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
define: {
__VERSION__: JSON.stringify(pkg.version),
'process.env.NODE_ENV': JSON.stringify(mode),
'process.env.PUBLIC_URL': JSON.stringify('./'),
},
2021-06-07 21:02:28 +08:00
base: './',
2022-05-08 18:37:08 +08:00
resolve: {
alias: {
$src: path.resolve(__dirname, './src'),
src: path.resolve(__dirname, './src'),
},
},
2021-05-30 16:33:27 +08:00
publicDir: 'assets',
build: {
2022-05-08 18:37:08 +08:00
// sourcemap: true,
2021-05-30 16:33:27 +08:00
// the default value is 'dist'
// which make more sense
// but change this may break other people's tools
outDir: 'public',
},
plugins: [
2022-05-08 18:37:08 +08:00
react(),
2021-05-30 16:33:27 +08:00
VitePWA({
srcDir: 'src',
outDir: 'public',
filename: 'sw.ts',
strategies: 'injectManifest',
2021-06-07 21:02:28 +08:00
base: './',
2021-05-30 16:33:27 +08:00
}),
],
}));