Created
April 12, 2023 16:27
-
-
Save cgnz0r/adcca371296ede3956f9104a8884692c to your computer and use it in GitHub Desktop.
vite: config.js instead of .env files
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
import { fileURLToPath } from "node:url"; | |
import { defineConfig } from 'vite' | |
import { resolve } from 'path' | |
import { viteStaticCopy } from 'vite-plugin-static-copy' | |
import vue from '@vitejs/plugin-vue' | |
import path from 'path' | |
const filesNeedToExclude = ['config.js'] | |
const filesPathToExclude = filesNeedToExclude.map((src) => { | |
return fileURLToPath(new URL(src, import.meta.url)) | |
}) | |
export default defineConfig(() => { | |
return { | |
base: './', | |
build: { | |
rollupOptions: { | |
external: [...filesPathToExclude] | |
} | |
} | |
plugins: [ | |
vue(), | |
viteStaticCopy({ | |
targets: [ | |
{ | |
src: path.resolve(__dirname, './config.js'), | |
dest: './' | |
} | |
] | |
}) | |
], | |
resolve: { | |
alias: { | |
'@': resolve(__dirname, 'src/') | |
} | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment