-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 including files just before manager.bundle.js #1134
Conversation
Context & Why? The process went like this: 1. Why are storybook's build times so slow (5 sec or more)? 2. Lets try adding the webpack dll plugin 3. Oh wait, now I need to include a vendor.js (it has the react bits) prior to storybook 4. This commit 5. Now build times are sub 200ms.
49bc32e
to
b390c34
Compare
Codecov Report
@@ Coverage Diff @@
## master #1134 +/- ##
=========================================
Coverage ? 12.73%
=========================================
Files ? 199
Lines ? 4577
Branches ? 725
=========================================
Hits ? 583
Misses ? 3352
Partials ? 642
Continue to review full report at Codecov.
|
Thanks for this PR!!! is this related to #1083 you think?.. Would it be an option to use DLLplugin by default? I haven't used it before, So I could use help with that. |
From my limited knowledge (reading an hour and this blog post), with the DLL plugin, its a two step thing.
// .storybook/vendor.webpack.config.js
var path = require("path");
var webpack = require("webpack");
module.exports = {
context: process.cwd(),
entry: {
vendor:[
'react',
'react-dom',
'react-router'
// any other "expensive" packages to build
]
},
output: {
filename: '[name].dll.js',
path: path.join(__dirname,'public'),
library: '[name]',
},
plugins: [
new webpack.DllPlugin({
path: path.join(__dirname,'public', "[name]-manifest.json"),
name: "[name]",
context: path.resolve(__dirname)
})
]
}; That outputs two files
Then in the webpack config being used by storybook, we incorporate the run time part which doesn't output chunks but reads in the generated manifest
Then any chunks at runtime will be expecting the pregenerated vendor script to be loaded prior to their execution.
So to answer one of your questions, It is related to #1083, but instead of dynamic chunks, its more about needing an additional explicit configurable list of public js files |
Right, that confirms what I thought it was. This will definitely be supported one way or another! Thank you so much for this crazy good PR! ❤️ |
This is amazing. Thanks for this wonderful PR. 🙇 |
@enjoylife I'm going to investigate adding / using the DLL plugin to speed up the builds for everyone! concerning this PR. What I think I'd like to do merge this, with a simple change. Right now your proposal is to add support for a
|
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.
Right now your proposal is to add support for a bodyscript.html
file.
We already have a head.html
file. As a consumer, I'd be really confused what file has what purpose.. What do you think of this suggestion:
- rename
head.html
topreview-head.html
* - add support for a new file called
manager-head.html
(*) if this file would not be found we would look for
head.html
for backwards compatibility.
We could display a deprecation warning ifhead.html
was provided, asking the user to rename it.
The original names in the pull request were hastily thought out... so if those changes better align with the existing naming conventions in storybook, then that is great! |
I'm can accept this PR if you change the filenames (with support for legacy Bonuspoints for adding this behavior to the docs! ❤️ |
@enjoylife Are you interested in updating this PR? Is there something I can do to help? |
@ndelangen, I updated the naming conventions as per our previous comments and added a few updates to the docs. |
@ndelangen I think you are doing something funky with |
@@ -70,6 +70,7 @@ export default function(data) { | |||
background-color: #eee | |||
} | |||
</style> | |||
${headHtml} |
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 think this is buggy when headHtml
is not defined
What I did
I simply followed the preexisting approach of including additional html, but instead of it being injected into the story iframe, it is injected in the index.html, right before the manager script.
This commit really was just to satisfy my issue detailed below, but the pull request is more an example for the maintainers to help solve a few outstanding issues/requests. See #678 , #686, #630.
Context & Why?
The process went like this:
How to test
Include a file called
bodyscript.html
in the storybook config directory, and you will see it be injected into the source.