Update Expo example app to enable static CSS extraction #238
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.
Why
ref. #236
This PR adds the ability to extract CSS in the example Expo app on the web by using postcss-react-strict-dom, as suggested in this comment.
How
runtimeInjection: opts.dev
hack and always setruntimeInjection
to falsemetro.config.js
instead to disable runtimeInjection but that disables debug classsName generation during development, so I changed the default to false to match the output with the original branch in dev@expo/metro-runtime
to enable Fast RefreshKnown issues
Code and Pre elements render discrepancy
code
andpre
elements seem smaller than the expected output. The expected font family for these elements aremonospace, monospace
(this code).However, in my branch the applied font-family is
monospace
.monospace, monospace
seems to be a hack to force browsers to render monospace fonts in the expected font-size but because of the property value normalization the hack gets removed.This seems to be an issue with Expo Web CSS post-processing, as removing postcss config and just writing
html { font-family: monospace, monospace; }
in the global css results in the same behavior.I suspect this to be related to the usage of lightningcss in Expo but I have not confirmed it.
https://github.com/expo/expo/blob/cd39671d70ad59277af77f156920002a148ca4a3/packages/%40expo/metro-config/src/transform-worker/transform-worker.ts#L222
Actual:
Expected:
Test Plan
npm run dev:web --clear
command in theapps/examples
directory.npx expo export -p web
to check that production builds successfully run and the generated static css is outputted toapps/examples/dist/_expo/static/css/*.css