1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-06 01:15:28 +02:00

chore: add file and component names to styled output class names in dev (#9351)

Updates the `vite.config.mts` file to include config for emotion,
telling it to add `<file name>--<component name>` to the class names
of generated components.

The class name modification only happens in development mode.
This commit is contained in:
Thomas Heartman 2025-02-24 14:45:20 +01:00 committed by GitHub
parent 7f81c38daa
commit 26e01177be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -37,54 +37,92 @@ const vitestConfig = vitestDefineConfig({
}, },
}); });
export default mergeConfig( export default defineConfig(({ mode }) => {
defineConfig({ const reactPluginArgs =
base: UNLEASH_BASE_PATH, mode === 'development'
build: { ? {
outDir: 'build', babel: {
assetsDir: 'static', plugins: [
assetsInlineLimit: 0, [
modulePreload: false, '@emotion',
cssCodeSplit: false, {
}, autoLabel: 'always',
server: { labelFormat: '[filename]--[local]',
open: true, importMap: {
host: true, '@mui/material': {
port: 3000, styled: {
proxy: { canonicalImport: [
[`${UNLEASH_BASE_PATH}api`]: { '@emotion/styled',
target: UNLEASH_API, 'default',
changeOrigin: true, ],
styledBaseImport: [
'@mui/material',
'styled',
],
},
},
},
},
],
],
},
}
: undefined;
return mergeConfig(
{
base: UNLEASH_BASE_PATH,
build: {
outDir: 'build',
assetsDir: 'static',
assetsInlineLimit: 0,
modulePreload: false,
cssCodeSplit: false,
},
server: {
open: true,
host: true,
port: 3000,
proxy: {
[`${UNLEASH_BASE_PATH}api`]: {
target: UNLEASH_API,
changeOrigin: true,
},
[`${UNLEASH_BASE_PATH}auth`]: {
target: UNLEASH_API,
changeOrigin: true,
},
[`${UNLEASH_BASE_PATH}logout`]: {
target: UNLEASH_API,
changeOrigin: true,
},
[`${UNLEASH_BASE_PATH}health`]: {
target: UNLEASH_API,
changeOrigin: true,
},
[`${UNLEASH_BASE_PATH}invite`]: {
target: UNLEASH_API,
changeOrigin: true,
},
[`${UNLEASH_BASE_PATH}edge`]: {
target: UNLEASH_API,
changeOrigin: true,
},
}, },
[`${UNLEASH_BASE_PATH}auth`]: { fs: {
target: UNLEASH_API, allow: ['..'],
changeOrigin: true,
},
[`${UNLEASH_BASE_PATH}logout`]: {
target: UNLEASH_API,
changeOrigin: true,
},
[`${UNLEASH_BASE_PATH}health`]: {
target: UNLEASH_API,
changeOrigin: true,
},
[`${UNLEASH_BASE_PATH}invite`]: {
target: UNLEASH_API,
changeOrigin: true,
},
[`${UNLEASH_BASE_PATH}edge`]: {
target: UNLEASH_API,
changeOrigin: true,
}, },
}, },
fs: { plugins: [
allow: ['..'], react(reactPluginArgs),
tsconfigPaths(),
svgr(),
envCompatible(),
],
esbuild: {
logOverride: { 'this-is-undefined-in-esm': 'silent' },
}, },
}, },
plugins: [react(), tsconfigPaths(), svgr(), envCompatible()], vitestConfig,
esbuild: { );
logOverride: { 'this-is-undefined-in-esm': 'silent' }, });
},
}),
vitestConfig,
);