-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[kbn/optimizer] only build specified themes #70389
[kbn/optimizer] only build specified themes #70389
Conversation
…-optimizer-theme-config
…lger/kibana into implement/kbn-optimizer-theme-config
- Removed the normal `_styling_constants.scss` file where possible - Still some legacy imports I don’t know what to do with
…lger/kibana into implement/kbn-optimizer-theme-config
…-optimizer-theme-config
…-optimizer-theme-config
…-optimizer-theme-config
…-optimizer-theme-config
…-optimizer-theme-config
…-optimizer-theme-config
Note: The rise in modules across bundles is expected as we're now building twice as many style modules for each production bundle. Most of these modules should be asynchronously loaded by applications and shouldn't cause load issues. |
Pinging @elastic/kibana-operations (Team:Operations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good for Canvas! We'll watch for the console spam.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…-optimizer-theme-config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, didn't test locally. Thanks for the detailed PR description!
… the total styles failed
…-optimizer-theme-config
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 🙇 Thank you!
I tested locally with the defaults in all themes (errors in k8) and then with *
(doesn't error in any theme) and all the correct SASS vars are passed through.
@@ -436,7 +436,7 @@ We are still to develop a proper process to accept any contributed translations. | |||
|
|||
When writing a new component, create a sibling SASS file of the same name and import directly into the JS/TS component file. Doing so ensures the styles are never separated or lost on import and allows for better modularization (smaller individual plugin asset footprint). | |||
|
|||
Any JavaScript (or TypeScript) file that imports SASS (.scss) files will automatically build with the [EUI](https://elastic.github.io/eui/#/guidelines/sass) & Kibana invisibles (SASS variables, mixins, functions) from the [`styling_constants.scss` file](https://github.com/elastic/kibana/blob/master/src/legacy/ui/public/styles/_styling_constants.scss). However, any Legacy (file path includes `/legacy`) files will not. | |||
All SASS (.scss) files will automatically build with the [EUI](https://elastic.github.io/eui/#/guidelines/sass) & Kibana invisibles (SASS variables, mixins, functions) from the [`globals_[theme].scss` file](src/legacy/ui/public/styles/_globals_v7light.scss). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉 !! I like the rename too
@import '@elastic/eui/src/global_styling/functions/index'; | ||
@import '@elastic/eui/src/global_styling/variables/index'; | ||
@import '@elastic/eui/src/global_styling/mixins/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got a PR up in EUI to make this import a single line for all themes. Doesn't block this PR, I'll do a follow up
💚 Build SucceededBuild metrics@kbn/optimizer bundle module count
History
To update your PR or re-run it, just comment with: |
Co-authored-by: spalger <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: cchaos <[email protected]> # Conflicts: # packages/kbn-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap
Co-authored-by: spalger <[email protected]> Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: cchaos <[email protected]>
* master: (32 commits) [Ingest Pipelines] Load from json (elastic#70297) [Rum Dashbaord] Rum selected service view (elastic#70579) [Uptime] Prevent duplicate requests on load for index status (elastic#70585) [ML] Changing shared module setup function parameters (elastic#70589) [Ingest Manager] Add ability to sort to agent configs and package configs (elastic#70676) [Alerting] document requirements for developing new action types (elastic#69164) Fixed adding an extra space character on selecting alert variable in action text fields (elastic#70028) [Maps] show vector tile labels on top (elastic#69444) chore(NA): upgrade to lodash@4 (elastic#69868) Add Snapshot Restore README with quick-testing steps. (elastic#70494) [EPM] Use higher priority than default templates (elastic#70640) [Maps] Fix cannot select Solid fill-color when removing fields (elastic#70621) [kbn/optimizer] only build specified themes (elastic#70389) Fix saved query modal overlay (elastic#68826) Update component templates list to render empty prompt inside of content container. Show detail panel when deep-linked, even if there are no component templates. (elastic#70633) [Security Solution] Renames the `Investigate in Resolver` Timeline action (elastic#70634) fix 400 error on initial signals search (elastic#70618) [Maps] fix unable to edit heatmap metric (elastic#70606) Update network idle timeout (elastic#70629) [APM] Disable flaky useFetcher test (elastic#70638) ...
Fixes #70353
This PR enables devs to customize which themes the
@kbn/optimizer
will build. By default we continue to build the v7 light and dark themes while removing some sass compilation options (sassOptions.importer
) to reduce the build time about 20% on my machine.For the subset of devs who don't normally need to switch between themes, the
KBN_OPTIMIZER_THEMES
environment variable can be used to build only a single theme, such asKBN_OPTIMIZER_THEMES=v7light
, which reduces the build time an additional 20% on my machine.For devs who are working on the new v8 theme support,
KBN_OPTIMIZER_THEMES=v8light,v8dark
can be used to swap for those themes instead, orKBN_OPTIMIZER_THEMES=*
can be used to build all four themes, at a the cost of additional build time.When Kibana is loaded with uiSettings requesting a different theme than the ones which were built an error is written to the console for each style file imported describing how an alternate theme was loaded and how to fix the issue by setting the
KBN_OPTIMIZER_THEMES
environment variable.Additional docs for theme support in the
@kbn/optimizer
can be found in the@kbn/optimizer
readmeI would prefer to show a toast notification when this occurs, but the styles are loaded in a context where communicating with the core services would require some serious hacks, and this is only a feature for development, so I've settled on spamming the console and hoping that people notice it.
@cchaos is going to help make sure that folks working on the design side of things know about this requirement.
Removing the sass importer config, which @restrry discovered was a huge performance issue for us, was done by splitting up the
styling_constants.scss
file so that there is now a specific styling_constants file for each theme. We now prepend the right file as necessary when we build each stylesheet for each theme (including legacy style files which only support the v7 theme).