Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(labware-library): fix labware-library css issue #16502

Merged
merged 5 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions labware-library/cssModuleSideEffect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Plugin } from 'vite'

/**
* Creates a Vite plugin that marks CSS modules as having side effects
*
koji marked this conversation as resolved.
Show resolved Hide resolved
* @returns {Plugin} The Vite plugin object.
*/

export const cssModuleSideEffect = (): Plugin => {
return {
name: 'css-module-side-effectful',
enforce: 'post',
transform(_: string, id: string) {
if (id.includes('.module.')) {
return {
moduleSideEffects: 'no-treeshake', // or true, which also works with slightly better treeshake
}
}
},
}
}
2 changes: 2 additions & 0 deletions labware-library/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import postCssApply from 'postcss-apply'
import postColorModFunction from 'postcss-color-mod-function'
import postCssPresetEnv from 'postcss-preset-env'
import lostCss from 'lost'
import { cssModuleSideEffect } from './cssModuleSideEffect'

const testAliases: {} | { 'file-saver': string } =
process.env.CYPRESS === '1'
Expand All @@ -30,6 +31,7 @@ export default defineConfig({
configFile: true,
},
}),
cssModuleSideEffect(), // Note for treeshake
],
optimizeDeps: {
esbuildOptions: {
Expand Down
Loading