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 2 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
13 changes: 13 additions & 0 deletions labware-library/cssModuleSideEffect.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const cssModuleSideEffect = (): any => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add some comments explaining what we're doing and why, and also maybe links to the github issue for vite? coming back later and understanding why we're doing this will be important. im sure this wont be the last time we have to deal with this 😢

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also add the appropriate TS types to this plugin?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to wanting comments with a link to the vite pr

return {
name: 'css-module-side-effectful',
enforce: 'post',
transform(_: any, id: any) {
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(),
],
optimizeDeps: {
esbuildOptions: {
Expand Down
Loading