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

feat: fix style build pipeline #278

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

anoblet
Copy link
Collaborator

@anoblet anoblet commented May 10, 2023

This fixes the style build pipeline while in development mode. In essence, it uses Google Wireit (https://github.com/google/wireit) to run yarn storybook and yarn build in parallel while also adding watch functionality to yarn build. Instead of running separate commands, we would just use yarn dev.

@anoblet anoblet requested a review from a team May 10, 2023 13:06
@github-actions
Copy link

github-actions bot commented May 10, 2023

size-limit report 📦

Path Size
packages/cxl-ui/pkg/dist-web/cxl-ui.js 33.57 KB (0%)
packages/cxl-ui/pkg/dist-web/cxl-ui-jwplayer.js 11.87 KB (0%)
packages/cxl-ui/pkg/dist-web/cxl-ui-playbooks.js 24.9 KB (0%)
packages/cxl-ui/pkg/dist-web/vendor.js 125.6 KB (0%)
packages/cxl-ui/pkg/dist-web/cxl-ui-jwplayer.js, packages/cxl-ui/pkg/dist-web/cxl-ui-playbooks.js, packages/cxl-ui/pkg/dist-web/cxl-ui.js, packages/cxl-ui/pkg/dist-web/manifest.js, packages/cxl-ui/pkg/dist-web/unresolved.js, packages/cxl-ui/pkg/dist-web/vendor.js 197.1 KB (0%)

Copy link

@pawelkmpt pawelkmpt left a comment

Choose a reason for hiding this comment

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

@anoblet I just tested and it works for me without any issues. You mentioned refinement on Slack. Anything specific?

package.json Outdated Show resolved Hide resolved
@anoblet anoblet force-pushed the anoblet/feat/style-build branch 4 times, most recently from 2ea3740 to 8077baa Compare May 10, 2023 14:02
@anoblet
Copy link
Collaborator Author

anoblet commented May 10, 2023

@pawelkmpt I moved wireit to devDependencies. I also improved the flow a bit so that first run is sequential and quicker. The dev command isn't really needed as it's just a passthrough to storybook, though if we want to keep it, we can.

@anoblet anoblet force-pushed the anoblet/feat/style-build branch from 8077baa to 2f33978 Compare May 10, 2023 14:08
@anoblet
Copy link
Collaborator Author

anoblet commented May 10, 2023

Should be ready for review.

@anoblet anoblet requested a review from pawelkmpt May 10, 2023 14:08
@anoblet anoblet force-pushed the anoblet/feat/style-build branch from 2f33978 to 40c0b1d Compare May 10, 2023 15:02
Comment on lines +37 to +53
"styles:build": {
"command": "node packages/sass-render/bin/sass-render.js -s \"packages/*/scss/**/*.scss\"",
"dependencies": [
"styles:clean"
],
"files": [
"packages/*/scss/**/*.scss"
]
},
"styles:clean": {
"command": "rimraf packages/**/styles/**/*.js"
},
"styles:watch": {
"command": "yarn run styles:build --watch",
"service": true
}
Copy link

Choose a reason for hiding this comment

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

Because wireit watcher doesn't have SASS-specific intelligence, this seems to render all SCSS files on any one change?

Copy link
Collaborator Author

@anoblet anoblet May 10, 2023

Choose a reason for hiding this comment

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

I do see that. There aren't very many files, and on my machine it doesn't take too long. Piping only changed files is a feature that they might implement: google/wireit#168.

Copy link

Choose a reason for hiding this comment

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

To me it's a pretty clear blocker until they solve it upstream.

For our partial watching problem, we could explore how to wire up native sass -w instead, similar to how packages/institute-theme does it. Wireit may or may not be a part of the solution, maybe it's still useful without its watcher function.

Copy link
Collaborator Author

@anoblet anoblet May 10, 2023

Choose a reason for hiding this comment

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

From what I gather, there's no way to determine that a change has been made to an imported file.

For example:

A change is made to packages\cxl-ui\scss\cxl-app-layout\_layout.scss. Run sass on packages\cxl-ui\scss\cxl-app-layout.scss.

The reason why build and build-styling work is because we do run sass-render on everything. Even if scripts/watcher.js is able to detect a change in packages\cxl-ui\scss\cxl-app-layout\_layout.scss, it won't update packages\cxl-ui\src\styles\cxl-app-layout-css.js.

Storybook won't refresh unless packages\cxl-ui\src\styles\cxl-app-layout-css.js is updated.

The best two solutions I see are:

  1. Get rid of partials
  2. Run sass-render on all files whenever any scss file is changed (which is pretty much what we do now manually).

@anoblet anoblet force-pushed the anoblet/feat/style-build branch from 40c0b1d to 62959cb Compare May 10, 2023 18:45
@anoblet anoblet force-pushed the anoblet/feat/style-build branch from 62959cb to f1b0b07 Compare May 10, 2023 19:32
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.

3 participants