-
-
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
CHANGE html-webpack-plugin for generate-page-plugin #3919
Conversation
@@ -32,7 +32,7 @@ export default class ReactProvider extends Provider { | |||
} | |||
|
|||
const queryString = qs.stringify(queryParams); | |||
const url = `iframe.html?${queryString}`; | |||
const url = `preview.html?${queryString}`; |
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.
Can't we make it backward compatible somehow? I like the name "preview" much more than "iframe", however, there are a lot of tools (like visual testing) that are accessing directly the iframe.html
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 we should actively update storyshots
and inform other things that rely on iframe.html
if we're making this change.
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.
@igor-dv I'll try it and ask for feedback. Could be that there will be pressure to keep it as is, and I might revert in that case.
We won't know unless we try & ask.
If you have good suggestions on backward compatibility whilst pressuring people to move to the new location (so we don't have to keep supporting both forever) I'd be happy to hear your suggestions?!
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.
@tmeasday ☝️
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.
@oblador 👆
@@ -32,7 +32,7 @@ export default class ReactProvider extends Provider { | |||
} | |||
|
|||
const queryString = qs.stringify(queryParams); | |||
const url = `iframe.html?${queryString}`; | |||
const url = `preview.html?${queryString}`; |
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 we should actively update storyshots
and inform other things that rely on iframe.html
if we're making this change.
I agree @danielduan please help, what do you mean with update storyshots? I'm aware some integrations might break, I don't think it will ever have to change after this, but Before releasing this we'll have to inform our known integrators such as Chromatic, Percy, Screener, Applitools. |
do a codebase wide search for |
Codecov Report
@@ Coverage Diff @@
## master #3919 +/- ##
==========================================
- Coverage 39.66% 39.58% -0.09%
==========================================
Files 433 433
Lines 5445 5467 +22
Branches 740 745 +5
==========================================
+ Hits 2160 2164 +4
- Misses 2903 2917 +14
- Partials 382 386 +4
Continue to review full report at Codecov.
|
Got it, changed it there too. |
I have pinged a few integrators about this potential change, I'm hoping to hear from them how big of an impact it would make. |
ERROR:
Ahh found that the manager html template was 'secretly' shared: Might be the case for the some other apps too. I need to move them all over to the new generatePagePlugin |
I thought about these few options:
Of course, all these should bump to the user a notification of a feature deprecation. |
I've extracted the generatePagePlugin into it's own repo and package, I think it could be useful outside of storybook. |
Integrators update: |
import { indexHtmlPath } from '@storybook/core/server'; | ||
import GeneratePagePlugin from 'generate-page-webpack-plugin'; | ||
|
||
import { getManagerHeadHtml } from '@storybook/core/dist/server/utils'; |
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 it's better to be exported from core/server
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
version, | ||
new GeneratePagePlugin( | ||
{ | ||
template: require.resolve('@storybook/core/dist/server/templates/index.html.ejs'), |
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.
And this one 🤷♂️
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
{ | ||
template: require.resolve('@storybook/core/dist/server/templates/index.html.ejs'), | ||
// eslint-disable-next-line global-require | ||
parser: require('ejs'), |
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.
Can't it be also imported up there ☝️
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.
sure
<script> | ||
if (window.parent !== window) { | ||
window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__REACT_DEVTOOLS_GLOBAL_HOOK__; | ||
window.__VUE_DEVTOOLS_GLOBAL_HOOK__ = window.parent.__VUE_DEVTOOLS_GLOBAL_HOOK__; |
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 we have these both in globals. Anyway it's strange to have them together 🤔
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.
See #102 (comment)
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.
Might look a little strange, but it's convenient I think. 0 complexity
40fd33d
to
07cf773
Compare
I think we should deprecate iframe but keep it around for one major version. It's easy and will give everyone time to adapt |
OK, next major release then |
@ndelangen To be clear, I mean:
|
@shilman yes, we can do that, but I've decided that I should do that in a separate PR, I'm sure you won't mind 👍 I also haven't quite figured our how to effectively do the backwards compatibility technically. I'm guessing the only way it could ever work was if it the static build creates both preview.html AND iframe.html.. I rebased this PR, it should be fairly simple to review now. |
07dcc76
to
604d9db
Compare
6a10a15
to
9be47de
Compare
9a7a7aa
to
85b73bd
Compare
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.
Can you please also handle my previous comments? They are mostly cleanups
lib/core/server.js
Outdated
indexHtmlPath: require.resolve('./src/server/index.html.ejs'), | ||
iframeHtmlPath: require.resolve('./src/server/iframe.html.ejs'), | ||
}); | ||
module.exports = assign({}, defaultWebpackConfig, buildStatic, buildDev, serverUtils, {}); |
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.
the last {}
is redundant
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.
fixed this
85b73bd
to
4218659
Compare
# Conflicts: # lib/core/package.json
# Conflicts: # app/react-native/package.json # lib/core/package.json # yarn.lock
353f489
to
db18161
Compare
I will merge this after alpha release today. |
<title>Storybook</title> | ||
<link rel="shortcut icon" href="favicon.ico?v=1" /> | ||
|
||
<% if (options.links) { %> |
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.
@ndelangen I'm trying to figure out how to plug into this for CSS files we extract out with mini-css-extract-plugin
, are there any pointers? Been digging for clues for the past couple of days.
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.
@diagramatics I'm happy to help out, do you have a repo I can use to debug this?
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.
Thanks! I have a repro on cra-kitchen-sink
in https://github.com/diagramatics/storybook/tree/repro-mini-css-extract-plugin, with the Webpack config extending the default config and replacing the style-loader
with mini-css-extract-plugin
.
You can replace mini-css-extract-plugin
with extract-text-webpack-plugin
to make it in parity with what create-react-app
has, but essentially if I understand correctly the issue is that GeneratePagePlugin
(and in extension, the Webpack config files to add the plugin in lib/core/src/server/config
) doesn't have a way to hook into these common CSS file extraction Webpack plugins to output them into this particular section of the index.html.ejs
template (options.links
).
Notice there's no options.links
specified. Not to mention there is no way we can pass generated CSS files in since this is not in the middle of any hook execution such as additionalChunkAssets
to inject the files in.
This is as much as I get digging around the codebase, so let me know if you need more info (or if I'm absolutely wrong 😅). I'm also on Slack by the same username.
This change introduces breaking changes in all projects that use html-webpack-plugins with custom storybook builds. This just murdered my svg-spritesheet generator plugin, thus all svg icons no longer show in storybook output 👎 |
@XPilot Let's find a solution to that together, by either extending the generate-page-webpack-plugin or injecting the svgs some other way. |
Issue: html-webpack-plugin is designed to generate 1 page. generating multiple pages, means creating a new plugin for each page that excludes all chunks but the 1 entrypoint you wanted to generate a page for.
What I did
How to test
Examples should run just fine, including dev-mode and static builds, there should be no changes in functionality.
Performance might be a little bit better since the plugin generatePagePlugin is a lot simpler then the html-webpack-plugin.
This is the first part of sbnext coming to the core 🎉.