-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added vite-plugin-env-compatible to use VUE_APP env prefix and …
…process.env
- Loading branch information
Showing
5 changed files
with
41 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
export default function env(name) { | ||
return ( | ||
import.meta.env?.[name] || | ||
window?.configs?.[name] || | ||
window?.configs?.[`VITE_${name}`] | ||
process.env[name] || | ||
window?.configs?.[`VUE_APP_${name}`] || | ||
process.env[`VUE_APP_${name}`] | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,25 @@ | ||
import { fileURLToPath, URL } from 'node:url'; | ||
|
||
import { defineConfig, loadEnv } from 'vite'; | ||
import { defineConfig } from 'vite'; | ||
import vue from '@vitejs/plugin-vue'; | ||
import vueJsx from '@vitejs/plugin-vue-jsx'; | ||
import env from 'vite-plugin-env-compatible'; | ||
|
||
// https://vitejs.dev/config/ | ||
export default ({ mode }) => { | ||
const env = loadEnv(mode, process.cwd(), ''); | ||
|
||
return defineConfig({ | ||
define: { | ||
'process.env': env, | ||
}, | ||
plugins: [vue(), vueJsx()], | ||
css: { | ||
preprocessorOptions: { | ||
scss: { | ||
additionalData: ` | ||
export default defineConfig({ | ||
plugins: [vue(), vueJsx(), env({ prefix: 'VUE_APP' })], | ||
css: { | ||
preprocessorOptions: { | ||
scss: { | ||
additionalData: ` | ||
@import '@weni/unnnic-system/src/assets/scss/unnnic.scss'; | ||
`, | ||
}, | ||
}, | ||
}, | ||
resolve: { | ||
alias: { | ||
'@': fileURLToPath(new URL('./src', import.meta.url)), | ||
}, | ||
}, | ||
resolve: { | ||
alias: { | ||
'@': fileURLToPath(new URL('./src', import.meta.url)), | ||
}, | ||
}); | ||
}; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters