Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Fix for #2998
Fix for #3760
In this PR I did a couple of changes to fix development and production environments when CSS modules are used.
First change was related to fix the generated JSON based on CSS module.
I moved JSON generation after transform plugins are applied, because the
.sass
,.less
or.css
(with postcss) should be transformed to CSS, and after that resulted CSS is ready to be transformed to JSON.Second change is related to
fileBuilder
. When.js
,.jsx
,.ts
or.tsx
file is transformed throughfileBuilder
for the case when it contains a.module.css
import, it requires to add an extra import to the generated JSON. It MUST be part of the final bundleEx. We have
import styles from './test.module.css'
import './test.module.css'
import styles from './test.module.css.json'
Why we need this?
Both files should be part of final bundle.
test.module.css'
- will be part of finalindex.css
, andtest.module.css.json
will be part of finalindex.js
Third change is to allow esbuild to add JSON files into the final bundle.
As I said the generated JSON based on
*.module.css
should be part of the bundle.Example
test.module.css
- I am using postcss with a couple of additional pluginsBefore change
test.module.css.json
generated JSON which is not included in the final bundlecontent in JS bundle
NOTE: content in CSS bundle - everything is OK
After change
test.module.css.json
is included in the final bundle and it lookscontent from CSS bundle
Testing
Docs