Update vite.config.mjs
This commit is contained in:
+5
-29
@@ -1,29 +1,18 @@
|
|||||||
import { defineConfig, loadEnv } from 'vite'
|
import { defineConfig } from 'vite'
|
||||||
import vue from '@vitejs/plugin-vue'
|
import vue from '@vitejs/plugin-vue'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import autoprefixer from 'autoprefixer'
|
import autoprefixer from 'autoprefixer'
|
||||||
|
|
||||||
export default defineConfig(({ mode }) => {
|
export default defineConfig(() => {
|
||||||
// Load .env
|
|
||||||
const viteEnv = loadEnv(mode, process.cwd(), '')
|
|
||||||
const env = {}
|
|
||||||
|
|
||||||
// Filter env to variables starting with VITE_APP or VUE_APP
|
|
||||||
Object.entries({...process.env, ...viteEnv}).forEach(([key, value]) => {
|
|
||||||
if (key.startsWith('VITE_APP') || key.startsWith('VUE_APP')) {
|
|
||||||
env[key] = value
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
plugins: [vue()],
|
plugins: [vue()],
|
||||||
base: './',
|
base: './',
|
||||||
css: {
|
css: {
|
||||||
postcss: {
|
postcss: {
|
||||||
plugins: [
|
plugins: [
|
||||||
autoprefixer({}) // add options if needed
|
autoprefixer({}), // add options if needed
|
||||||
],
|
],
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: [
|
alias: [
|
||||||
@@ -41,16 +30,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
replacement: path.resolve(__dirname, '/src'),
|
replacement: path.resolve(__dirname, '/src'),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
extensions: [
|
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue', '.scss'],
|
||||||
'.mjs',
|
|
||||||
'.js',
|
|
||||||
'.ts',
|
|
||||||
'.jsx',
|
|
||||||
'.tsx',
|
|
||||||
'.json',
|
|
||||||
'.vue',
|
|
||||||
'.scss',
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 3000,
|
port: 3000,
|
||||||
@@ -58,9 +38,5 @@ export default defineConfig(({ mode }) => {
|
|||||||
// https://vitejs.dev/config/server-options.html
|
// https://vitejs.dev/config/server-options.html
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
define: {
|
|
||||||
// vitejs does not support process.env so we have to redefine it
|
|
||||||
'process.env': env,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user