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

Transform Sass asset file extensions in block.json #430

Merged
merged 4 commits into from
Dec 23, 2024

Conversation

cr0ybot
Copy link
Contributor

@cr0ybot cr0ybot commented Dec 3, 2024

Related Issue/RFC: #419

Description of the Change

When a Sass file is used as a custom block asset, and the asset is set to a .css file in block.json, an error is thrown related to automatic version string generation because a file with that name and extension are not available in the source folder.

This PR duplicates the existing functionality that transforms TypeScript asset extensions in block.json for Sass files (.sass/.scss => .css).

block.json input:

{
  "style": "file:./style.scss"
}

block.json output:

{
  "style": "file:./style.css"
}

Alternate Designs

I could have changed the way that the version string generator works, but that is much less straightforward than just providing the file that the existing code is looking for (while also following the existing example set by the treatment of TypeScript files).

Possible Drawbacks

I realize that 10up seems to be moving away from Sass, but the workflow still inherently supports it.

A possible, but tiny, drawback is that this will likely change the generated version string in existing projects.

Verification Process

I verified the fix by running npm start in an existing project where I discovered the original issue. I also added and ran the tests successfully.

Checklist:

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests passed.
  • I have added a changeset to my PR. See CONTRIBUTING document for instructions

Copy link

changeset-bot bot commented Dec 3, 2024

🦋 Changeset detected

Latest commit: 6573d42

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
10up-toolkit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cr0ybot
Copy link
Contributor Author

cr0ybot commented Dec 10, 2024

Let me know if this should include a change to the documentation. I didn't see anything about block.json and TypeScript specifically in the docs so I didn't include anything, but it could be warranted.

Copy link
Member

@fabiankaegy fabiankaegy left a comment

Choose a reason for hiding this comment

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

Thanks so much for working on this. Nice job on the tests also!

I also ran a few tests on my end and it all works as expected :)

Merging this now and will see if we can get a release out the door early in the new year 👍

@fabiankaegy fabiankaegy merged commit 9f58b90 into 10up:develop Dec 23, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants