Created
January 29, 2025 14:45
-
-
Save sfreytag/24f940cf3309338a413ea4efb4d368d0 to your computer and use it in GitHub Desktop.
Vite build time white labelling
This file contains hidden or 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
// 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