Skip to content

Instantly share code, notes, and snippets.

@sfreytag
Created January 29, 2025 14:45
Show Gist options
  • Save sfreytag/24f940cf3309338a413ea4efb4d368d0 to your computer and use it in GitHub Desktop.
Save sfreytag/24f940cf3309338a413ea4efb4d368d0 to your computer and use it in GitHub Desktop.
Vite build time white labelling
// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { loadEnv } from 'vite'
import { join } from 'path'
export default () => {
// Load the env
const env = loadEnv('all', join(process.cwd(), './'))
// Look up the source folder for the given sector - care, or transport, or education, etc
const sectorSrc = process.cwd() + '/src/sectors/' + env.SECTOR
return defineConfig({
plugins: [
{
// Copy logos and CSS customisations from the sector into the
// default place for the build
...viteStaticCopy({
targets: [
{
src: sectorSrc,
dest: '' // Somewhere appropriate for the build
}
],
}),
enforce: 'pre' // Make it run before core vite plugins, like the actual build
},
vue(),
],
resolve: {
// as usual
},
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment