Skip to content

Instantly share code, notes, and snippets.

@cgnz0r
Created April 12, 2023 16:27
Show Gist options
  • Save cgnz0r/adcca371296ede3956f9104a8884692c to your computer and use it in GitHub Desktop.
Save cgnz0r/adcca371296ede3956f9104a8884692c to your computer and use it in GitHub Desktop.
vite: config.js instead of .env files
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