From 9970d14c40b5e10a493731545adbf55bd3fef86a Mon Sep 17 00:00:00 2001 From: Pedro Ladaria Date: Fri, 29 Nov 2024 15:53:17 +0100 Subject: [PATCH 1/2] WEB-2115 use custom identifier generation --- vite.config.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/vite.config.js b/vite.config.js index f61de19b39..9fdc15d7d1 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,11 +4,23 @@ import react from '@vitejs/plugin-react'; import {vanillaExtractPlugin} from '@vanilla-extract/vite-plugin'; import noBundlePlugin from 'vite-plugin-no-bundle'; import preserveDirectivesPlugin from 'rollup-plugin-preserve-directives'; +import {version as packageVersion} from './package.json'; + +/** + * Identifiers must start with a letter (not number) and can't contain dots + * Removing trailing zeros to reduce the size of the identifier + * + * 1.2.3 => v1_2_3 + * 1.2.0 => v1_2 + */ +const version = 'v' + packageVersion.replace(/[0\.]+$/, '').replace(/\./g, '_'); export default defineConfig({ plugins: [ react(), - vanillaExtractPlugin(), + vanillaExtractPlugin({ + identifiers: ({hash}) => `${version}_${hash}`, + }), noBundlePlugin({ // Change .css.js files to something else so that they don't get re-processed by consumer apps using vanilla extract too fileNames: ({name}) => `${name.replace(/\.css$/, '.css-mistica')}.js`, From dbd799dcac41d9a5060a5f13c9894b226beff79c Mon Sep 17 00:00:00 2001 From: Pedro Ladaria Date: Fri, 29 Nov 2024 15:55:53 +0100 Subject: [PATCH 2/2] WEB-2115 fix regex --- vite.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vite.config.js b/vite.config.js index 9fdc15d7d1..3e1eb92b15 100644 --- a/vite.config.js +++ b/vite.config.js @@ -12,8 +12,9 @@ import {version as packageVersion} from './package.json'; * * 1.2.3 => v1_2_3 * 1.2.0 => v1_2 + * 1.0.0 => v1 */ -const version = 'v' + packageVersion.replace(/[0\.]+$/, '').replace(/\./g, '_'); +const version = 'v' + packageVersion.replace(/(\.0)*$/, '').replace(/\./g, '_'); export default defineConfig({ plugins: [