build: upgrade Vite to 5.x
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import path from 'node:path'
|
||||
import autoprefixer from 'autoprefixer'
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
// Load .env
|
||||
const env = loadEnv(mode, process.cwd(), '')
|
||||
process.env = { ...process.env, ...env }
|
||||
|
||||
return {
|
||||
plugins: [vue()],
|
||||
base: './',
|
||||
css: {
|
||||
postcss: {
|
||||
plugins: [
|
||||
autoprefixer({}) // add options if needed
|
||||
],
|
||||
}
|
||||
},
|
||||
resolve: {
|
||||
alias: [
|
||||
// webpack path resolve to vitejs
|
||||
{
|
||||
find: /^~(.*)$/,
|
||||
replacement: '$1',
|
||||
},
|
||||
{
|
||||
find: '@/',
|
||||
replacement: `${path.resolve(__dirname, 'src')}/`,
|
||||
},
|
||||
{
|
||||
find: '@',
|
||||
replacement: path.resolve(__dirname, '/src'),
|
||||
},
|
||||
],
|
||||
extensions: [
|
||||
'.mjs',
|
||||
'.js',
|
||||
'.ts',
|
||||
'.jsx',
|
||||
'.tsx',
|
||||
'.json',
|
||||
'.vue',
|
||||
'.scss',
|
||||
],
|
||||
},
|
||||
server: {
|
||||
port: 3000,
|
||||
proxy: {
|
||||
// https://vitejs.dev/config/server-options.html
|
||||
},
|
||||
},
|
||||
define: {
|
||||
// vitejs does not support process.env so we have to redefine it
|
||||
'process.env': process.env,
|
||||
},
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user