-
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
[canvas][storybook] Improve Storybook Performance #34757
Changes from 4 commits
daae95e
3e0de5c
b7b4ce7
21d9395
e8e0608
ef12162
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
"license": "Elastic-License", | ||
"scripts": { | ||
"kbn": "node ../scripts/kbn", | ||
"kbn:bootstrap": "rm -rf ../built_assets/canvasStorybookDLL", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Curious why is this necessary? Shouldn't it get overwritten when it's built? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We want to force a rebuild of the DLL only if the packages change. We don't want to rebuild the DLL on every startup, just when the dependencies are updated. |
||
"start": "gulp dev", | ||
"build": "gulp build", | ||
"testonly": "gulp testonly", | ||
|
@@ -116,8 +117,7 @@ | |
"pdfjs-dist": "^2.0.943", | ||
"pixelmatch": "4.0.2", | ||
"proxyquire": "1.7.11", | ||
"react-docgen-typescript-loader": "^3.0.0", | ||
"react-docgen-typescript-webpack-plugin": "^1.1.0", | ||
"react-docgen-typescript-loader": "^3.1.0", | ||
"react-hooks-testing-library": "^0.3.8", | ||
"react-test-renderer": "^16.8.0", | ||
"react-testing-library": "^6.0.0", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
const path = require('path'); | ||
|
||
const DLL_NAME = 'canvasStorybookDLL'; | ||
const KIBANA_ROOT = path.resolve(__dirname, '../../../..'); | ||
const BUILT_ASSETS = path.resolve(KIBANA_ROOT, 'built_assets'); | ||
const DLL_OUTPUT = path.resolve(BUILT_ASSETS, DLL_NAME); | ||
|
||
module.exports = { | ||
DLL_NAME, | ||
KIBANA_ROOT, | ||
BUILT_ASSETS, | ||
DLL_OUTPUT, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
// This file defines CSS and Legacy style contexts for use in the DLL. This file | ||
// is also require'd in the Storybook config so that the Storybook Webpack instance | ||
// is aware of them, and can load them from the DLL. | ||
|
||
// Pull in the built CSS produced by the Kibana server, but not | ||
// the Canvas CSS-- we want that in the HMR service. | ||
const css = require.context( | ||
'../../../../built_assets/css', | ||
true, | ||
/\.\/plugins\/(?!canvas).*light\.css/ | ||
); | ||
css.keys().forEach(filename => { | ||
css(filename); | ||
}); | ||
|
||
// Include Legacy styles | ||
const uiStyles = require.context( | ||
'../../../../src/legacy/ui/public/styles', | ||
false, | ||
/[\/\\](?!mixins|variables|_|\.|bootstrap_(light|dark))[^\/\\]+\.less/ | ||
); | ||
uiStyles.keys().forEach(key => uiStyles(key)); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<!-- | ||
This file is looked for by Storybook and included in the HEAD element | ||
if it exists. This is how we load the DLL content into the Storybook UI. | ||
--> | ||
<script src="/dll.js"></script> | ||
<link href="/dll.css" rel="stylesheet" /> |
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.
Was there supposed to be a wait defined for the debounce here?
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.
Hmm... I'm not sure. I saw this methodology elsewhere in Kibana for a watch flag, so I took it as the best approach.