[Beta] Update package exports#4624
Merged
Merged
Conversation
mejiaj
commented
Apr 12, 2022
mejiaj
commented
Apr 12, 2022
mejiaj
commented
Apr 14, 2022
| "./js/*": "./packages/*.js", | ||
| "./css/*": "./dist/css/*", | ||
| "./scss/*": "./dist/scss/*", | ||
| "./img/*": "./dist/img/*", |
Contributor
Author
There was a problem hiding this comment.
This export "./img/*": "./dist/img/*", allows us to import images in React like so:
// example.js
import us_flag_small from "@uswds/uswds/img/us_flag_small.png";
return (
…USA banner markup
<img
className="usa-banner__header-flag"
src={ us_flag_small }
alt="U.S. flag"
/>
);
mejiaj
commented
Apr 15, 2022
| "./src/img/*": "./packages/usa-icon/src/img", | ||
| "./js/*": "./packages/*.js", | ||
| "./css/*": "./dist/css/*", | ||
| "./scss/*": "./dist/scss/*", |
Contributor
Author
There was a problem hiding this comment.
Due to updated paths "./scss/*": "./dist/scss/*" requires includePaths in webpack. Which would mean users would have to eject their app and include the paths in their config.
Contributor
Author
There was a problem hiding this comment.
Needs further testing
I've been able to follow this create-react-app guidance to add some include paths without ejecting app. Results have been mixed.
// .env
SASS_PATH=./node_modules:./node_modules/@uswds:./node_modules/@uswds/uswds/packages// my-stylesheet.scss
@use "uswds-core" as *;
body {
background-color: color("green-40v");
}
6 tasks
thisisdano
approved these changes
Apr 18, 2022
This file contains hidden or 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
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.
Description
Updated package export paths. Export paths in
package.jsonare updated to reflect the new package structure.Users can take advantage of updated path exports to avoid unnecessarily long paths to assets in new structure.
Example
Importing CSS
Importing images
Additional information
Before you hit Submit, make sure you’ve done whichever of these applies to you:
npm testand make sure the tests for the files you have changed have passed.