Skip to content

Commit

Permalink
Update vite.config.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrholek authored Jun 14, 2024
1 parent 6b9c7c6 commit dfa4381
Showing 1 changed file with 5 additions and 29 deletions.
34 changes: 5 additions & 29 deletions vite.config.mjs
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import { defineConfig, loadEnv } from 'vite'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'node:path'
import autoprefixer from 'autoprefixer'

export default defineConfig(({ mode }) => {
// 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
}
})

export default defineConfig(() => {
return {
plugins: [vue()],
base: './',
css: {
postcss: {
plugins: [
autoprefixer({}) // add options if needed
autoprefixer({}), // add options if needed
],
}
},
},
resolve: {
alias: [
Expand All @@ -41,26 +30,13 @@ export default defineConfig(({ mode }) => {
replacement: path.resolve(__dirname, '/src'),
},
],
extensions: [
'.mjs',
'.js',
'.ts',
'.jsx',
'.tsx',
'.json',
'.vue',
'.scss',
],
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': env,
},
}
})

0 comments on commit dfa4381

Please sign in to comment.