-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
WIP: Static rendering #330
base: master
Are you sure you want to change the base?
Conversation
examples/.gitignore
Outdated
@@ -0,0 +1 @@ | |||
**/styleguide/*.js |
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.
We already have rules in global gitignore:
/examples/**/styleguide/build
/examples/**/styleguide/index.html
Scripts should be in a separate folder anyway.
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.
Oh I see. Is there a reason for them to be in a separate dir BTW?
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.
Better UI: not to scare users with extra files and make index.html
easier to find ;-)
It looks like I was able to render everything besides the actual components (which is by design) statically using latest commit. This includes:
We'll need to take some care of injecting CSS into |
package.json
Outdated
@@ -58,15 +57,18 @@ | |||
"loader-utils": "^0.2.16", | |||
"lodash": "^4.17.4", | |||
"minimist": "^1.2.0", | |||
"node-noop": "^1.0.0", |
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.
lodash/noop
should be enough ;-)
scripts/build.js
Outdated
// require('fs').writeFileSync('stats.json', JSON.stringify(stats.toJson())); | ||
callback(err, stats); | ||
// Firstly, build static "server" bundle | ||
return webpack(makeWebpackConfig(config, 'production', true), (err, stats) => { |
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 we pass an array of webpack config 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.
Can you elaborate on passing an array here? What do you mean exactly? How would this change it?
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.
As I understand you can call webpack like this: webpack([config1, config2])
.
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.
Yes, but this isn't the same. This will produce 2 compiler's processes but we want to share one process.
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.
How do you share it? I see two separate webpack
calls with different configs.
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.
Actually you might be right about it. I was a bit confused. Let me try it out.
import React, { PropTypes } from 'react'; | ||
import HTMLDocument from 'react-html-document'; | ||
|
||
function getScrtips(assets) { |
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.
This should be in HtmlDocument.js
. The idea is to provide a simple way to redefine rendering of components, so data and markup should be separated.
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.
Agreed! Will refactor appropriately.
{ name: 'charset', content: 'utf-8' }, | ||
]} | ||
> | ||
{ children } |
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’m wondering why ESLint don’t complain about this spaces… 🤔
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.
No rule defined?
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’ll check ;-)
Codecov Report
@@ Coverage Diff @@
## master #330 +/- ##
==========================================
- Coverage 94.77% 94.77% -0.01%
==========================================
Files 75 78 +3
Lines 995 1014 +19
Branches 202 211 +9
==========================================
+ Hits 943 961 +18
- Misses 52 53 +1
Continue to review full report at Codecov.
|
@okonet I am not aware of decision details, it seems like react-jss would be a good fit here. In any case its easy. You can always create a |
- Use proper `charSet` key for the metatag as of venmo/react-html-document#9 - Moved metatags to renderer to allow easy customization without merging
@kof can you commit the solution you're suggesting? |
@okonet @kof Basically these two lines. We need to merge styles with user’s styles and and also pass merged theme object. And strip I’m not sure it’s all possible to do with react-jss and what would be the best solution. |
Btw. |
react-jss uses options.meta property if you pass it, otherwise it falls back to a component name https://github.com/cssinjs/react-jss/blob/master/src/index.js#L36 |
Why do you call them SomethingRenderer anyways and then replace the Renderer part in order to have nicer meta attributes on style tags? Why not to remove the Renderer thing from the name from the beginning? If it is not a container component, it is a renderer anyways, containers have no sheets. |
Ok, I have finished the SSR integration for JSS. I needed to do 2 suboptimal things, because of "react-html-document" component limitations.
|
Hmm, that makes me think if we still should use HtmlDocument. Right now it looks as hack. Are there any better options to do that @kof? |
Yes, simple template string like here |
Or optionally own document renderer component without that dependency. |
How own renderer would help us here? |
|
Optionally this can be done by sending a pr to that original package and make this possible. |
@kof do you mind updating the PR by removing the |
I think I can make it happen |
@kof Awesome! |
@kof any news on this one? |
@okonet not yet, could find time right now, because on the trip |
@sapegin NOOOO! Why did you close it? |
I’ve removed the |
|
@kof do you think you could find some time to get this done any soon? |
We probably need to create another branch first because this one is probably from 4.x and it would be a nightmare to merge master to it. |
Will be hard, I have a great deal of issues on jss project. |
Can be closed probably. |
This PR implements static rendering of the styleguide when building for production.
🚧🚧🚧
Please don't merge yet. Still WIP!!!
🚧🚧🚧