Merge pull request #310 from nicomt/process-env-filter
Filter environment variables
This commit is contained in:
+5
-22
@@ -1,22 +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 env = loadEnv(mode, process.cwd(), '')
|
|
||||||
process.env = { ...process.env, ...env }
|
|
||||||
|
|
||||||
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: [
|
||||||
@@ -34,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,
|
||||||
@@ -51,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': process.env,
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user