-
Notifications
You must be signed in to change notification settings - Fork 945
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
Update sharetribe-scripts to CRA v4 and add vanilla CSS support #1374
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Gnito
force-pushed
the
cra4-base
branch
3 times, most recently
from
November 3, 2020 18:32
7a1761d
to
3a0c0f0
Compare
Gnito
force-pushed
the
cra4-base
branch
2 times, most recently
from
November 17, 2020 00:01
3920805
to
928ad51
Compare
(including CSS vars set to root element)
Correct imports for styles/marketplaceDefaults.css
Gnito
changed the title
WiP: CRA 4 base branch
Update sharetribe-scripts with CRA 4 and vanilla CSS support
Nov 17, 2020
Gnito
changed the title
Update sharetribe-scripts with CRA 4 and vanilla CSS support
Update sharetribe-scripts to CRA v4 and add vanilla CSS support
Nov 17, 2020
This was referenced Nov 17, 2020
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
*.module.css
Our usage of CSS Modules started before Create React App (CRA) started to use it - and at the time we made a choice to push all the component styles through it. When different frameworks (incl. CRA) started to take CSS Modules into use, the naming pattern of
*.module.css
started to take hold. When making this update for our CRA fork (sharetribe-scripts), we decided to adopt this naming pattern.*.css
file naming pattern:root
element scope (aka<html>
element) as before,but they are now made through a single file:
marketplaceDefaults.css
.propertySets.css
propertySets.css
file is the only file that needs to be imported using@import
in component stylesheets.@import
should be avoided since it will be multiplied in dev mode.<style>
elements to include CSS files and@imports
would repeat shared code in each<style>
tag.@apply
rule, have the import for propertySets.css file.src/styles/
*
*
:Tests needed to be updated because our setup (ComponentName.css) has always been mapped to empty export:
Now that the CSS Modules is parsed separately, Jest is wired to use "identity-obj-proxy". In practice, that converts
className={css.someStyle}
toclassName="someStyle"
in Jest snapshots.It is possible to take the previous setup into use by adding Jest/moduleNameMapper overwrite into package.json.
In addition, there needs to be cssTransform.js in the root directory of the app.
Taking update from upstream
Otherwise, the file don't go through CSS Modules preprocessor.
import css from 'ComponentName.css'
=>import css from 'ComponentName.module.css'
e.g.
@import '../../styles/propertySets.css';
yarn run test
)src/styles/marketplaceDefaults.css contains
src/styles/propertySets.css contains
Note:
import css from .*(?<!\bmodule\b)\.css