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

Allow users to import sass files via Webpack sass-loader #2647

Merged
merged 4 commits into from
Jun 9, 2022

Conversation

vanitabarrett
Copy link
Contributor

@vanitabarrett vanitabarrett commented May 27, 2022

Fixes #2645

What

Add sass field to package.json exports.

Why

Webpack prefers the "exports" field over any other entry in the package.json, which is why the existing sass entry is not enough.

exports field is preferred over other package entry fields like main, module, browser or custom ones

https://webpack.js.org/guides/package-exports/

Vanita Barrett added 2 commits May 27, 2022 10:37
Allows users to import all.scss in their own sass files using:

`@import "govuk-frontend"`

May only be supported by Webpack at the moment
https://webpack.js.org/guides/package-exports/#conditions
Allows users to directly import certain sass files, e.g:

```
@import "govuk-frontend/govuk/base";
@import "govuk-frontend/govuk/all.scss";
@import "govuk-frontend/govuk/all";
@import "govuk-frontend/govuk/core/all";
@import "govuk-frontend/govuk/objects/all";
```
@vanitabarrett vanitabarrett changed the title [WIP] Allow users to import sass files via Webpack sass-loader Allow users to import sass files via Webpack sass-loader May 30, 2022
Similar to adding "./govuk/" to package.json, this lets tools know that these
paths are also available.
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2647 May 30, 2022 10:03 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2647 May 30, 2022 10:25 Inactive
Base automatically changed from require-js-fix to main June 7, 2022 09:46
@vanitabarrett vanitabarrett marked this pull request as ready for review June 7, 2022 09:47
@vanitabarrett vanitabarrett requested a review from a team June 7, 2022 09:48
Copy link
Contributor

@domoscargin domoscargin left a comment

Choose a reason for hiding this comment

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

This looks good to me, and users seem happy. A bit wary of doing something that's not part of the official spec, but this is probably the right quick fix.

Hopefully the bundler problem whack-a-mole ends with this issue!

@vanitabarrett vanitabarrett merged commit 89b4d21 into main Jun 9, 2022
@vanitabarrett vanitabarrett deleted the import-sass-fix branch June 9, 2022 08:18
@domoscargin domoscargin mentioned this pull request Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4.1.0 Breaks the ability to import scss files with webpack sass-loader
3 participants