Skip to content
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

Enable React-Hot-Reloader with Webpack #631

Merged
merged 1 commit into from
May 10, 2015
Merged

Enable React-Hot-Reloader with Webpack #631

merged 1 commit into from
May 10, 2015

Conversation

mtscout6
Copy link
Member

@mtscout6 mtscout6 commented May 8, 2015

Now that we have the webpack-dev-server running in a separate process it's time to enable hot reload for an even more amazing development experience.

Issues still to resolve.

  • Had to remove usage of client loader for performance reasons, which breaks the CodeMirror support
  • Remove in browser babel transformer webpack error
  • Fix carousel image request urls for examples. Thumbnails will need this too when [added] Thumbnail component including docs and tests #488 comes in
  • DRY up docs/dev-run script
  • Update docs README

@mtscout6 mtscout6 changed the title WIP: Enable React-Hot-Reload with Webpack WIP: Enable React-Hot-Reloader with Webpack May 8, 2015
@mtscout6
Copy link
Member Author

mtscout6 commented May 9, 2015

I put up a youtube video demonstrating these changes.

@mtscout6 mtscout6 changed the title WIP: Enable React-Hot-Reloader with Webpack Enable React-Hot-Reloader with Webpack May 9, 2015
@mtscout6
Copy link
Member Author

mtscout6 commented May 9, 2015

@react-bootstrap/collaborators That should be everything for this to work.

@mtscout6
Copy link
Member Author

mtscout6 commented May 9, 2015

Actually I found one more thing, just a minute.

@mtscout6
Copy link
Member Author

mtscout6 commented May 9, 2015

Ok, now it should be good.

@@ -11,10 +11,26 @@ Pages](http://pages.github.com/).
From the repository root run `npm run docs` and navigate your browser to
`http://localhost:4000`. This will start an express base node server with
webpack-dev middleware that will watch your file changes and recompile all the
static assets needed to generate the site.
static assets needed to generate the site. In the console output you'll see that
that we bind to two ports. The first port is the one you'll use to load the docs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'll see that that two that ?
I maybe wrong. Eng is not my native.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If that's the worst thing in this you can find, then I guess I can fix it 😉

@@ -21,8 +21,11 @@ if (development) {
});

app.use(function renderApp(req, res) {
res.header('Access-Control-Allow-Origin', target);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webpack/webpack-dev-server#70

in webpack.config.js

devServer: {
  headers: { 'Access-Control-Allow-Origin': '*' },
  headers: { 'Access-Control-Allow-Headers': 'X-Requested-With' }
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the server.js script is not run in the same process as the webpack-dev-server. We need the process doing the server side rendering to allow requests to a different service. If you took this out then you'd run into errors in the browser due to cross origin request violations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had commented out both lines Access-*,
then npm run docs,
then open in browser all pages with opened dev-console.
All is working and clear. Navigation, components rendering.

Then I had changed code on two pages: Components and Intro
and those changes showed up in browser as it should be.

No errors at all.

What should I do to reproduce cross origin request violations errors ?

@@ -27,7 +27,6 @@ export default (config, options) => {
jsLoader = value.loader;

return _.extend({}, value, {
loader: jsLoader + '!client',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand we can remove "client-loader": "0.0.1", from package.json ?
I didn't downloaded this PR yet.
Only looking through diffs on GitHub.
(and you've already made three fixes 😄 what caused me to refresh this page three times)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make one more!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed 😄 thanks for finding that.

+ Enable webpack-hot-loader for css changes
+ Enable react-hot-loader for component changes with state retention.
+ Better fail over when nodemon process fail
+ If you change the webpack configuration this will restart the
webpack-dev-server.
+ Video link to demo this feature in docs readme.
@AlexKVal
Copy link
Member

AlexKVal commented May 9, 2015

Whaaahh! Coool.
I press Save and page is self updating. 💥
✨ ✨ ✨ ✨

And it is so fast now ✈️

I like it a lot. Thank you! 👍

@mtscout6
Copy link
Member Author

mtscout6 commented May 9, 2015

I've been wanting this for a while myself, just been dragging my feet on the dirty work...

@AlexKVal
Copy link
Member

AlexKVal commented May 9, 2015

Actually today you already marked as done second item in my ToDo list. 😄 👍

// Remove extract text plugin from dev workflow so hot reload works on css.

If we could remove it at all it would be nice 😃

@mtscout6
Copy link
Member Author

mtscout6 commented May 9, 2015

It's still worth keeping that plugin for the production build, since it allows us to parallelize the download of JavaScript and CSS.

@AlexKVal
Copy link
Member

AlexKVal commented May 9, 2015

...just been dragging my feet on the dirty work...

If you mean burden of maintenance, I understand you now.
It's a lot of work and it needs to be done everyday.

@AlexKVal
Copy link
Member

AlexKVal commented May 9, 2015

It's still worth keeping that plugin for the production build, since it allows us to parallelize the download of JavaScript and CSS.

I am not finished yet my learning of the whole process, so I didn't know it.
But that bug in that project is on my ToDo also 😉

@dozoisch
Copy link
Member

dozoisch commented May 9, 2015

nice job

AlexKVal added a commit that referenced this pull request May 10, 2015
Enable React-Hot-Reloader with Webpack
@AlexKVal AlexKVal merged commit 3017b18 into master May 10, 2015
@mtscout6 mtscout6 deleted the hot-reload branch May 17, 2015 19:18
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants