jedwards1211 / meteor-webpack-react

(DEPRECATED) use jedwards1211/crater instead
https://github.com/jedwards1211/crater
374 stars 75 forks source link

How to build a product version and deploy it with MUP? #56

Open tomitrescak opened 8 years ago

tomitrescak commented 8 years ago

Hi, kudos on having transformation to Meteor 1.2 with 0% problems ;) I guess this solution will not be using the jsx and ecmascript capabilities of Meteor, but using the webpack ones, right?

Also, how do I deploy my meteor app? There are prod / dev and build commands, but I'm not sure how they relate to deployment. Do I need to run build prior to packaging my application with MUP from the meteor_core directory?

Thanks!

AdamBrodzinski commented 8 years ago

I imagine all will be the same with 1.2 with the exception of being able to opt out of Blaze and use the static-html package.

Also, how do I deploy my meteor app?

Ah so this is bit confusing now. Basically you need to run ./prod let it build, then kill the watcher with ctrl-c. You could also modify your .prod script so that it removes the --watch commands and doesn't boot up meteor.

Then you can just meteor deploy or with MUP you can create mup.json in the root, then setup the app directory to point to meteor_core and then from the root just mup setup/deploy.

However if you're using settings.json in the app I think it looks for settings.json in the same directory. If you have multiple environments (staging/prod) you might need to rename the current settings file or symlink them into another folder.

I'm hoping to have some free time this weekend to make a deploy script.

tomitrescak commented 8 years ago

Adam, good news ;) I'll wait for the script, or if you need help just let me know if I can do something about it. Just so you know, I have almost finished swith of all our uni applications to this solution. The biggest pain was to rewrite the whole frontend to react, but doing so I managed to improve the whole thing tremedously ... and you gotta love the code patching ;) One possible improvement would be, that if change in code cannot be handled by code patching an automatic page refresh could be performed .. but pressing CMD + R is not an issue.

tomitrescak commented 8 years ago

Hello @AdamBrodzinski Any progress on this? I tried what you proposed, but am getting a blank screen. I need to test the environment variables if they are propaerly set, as with the devel version it's not going well.

AdamBrodzinski commented 8 years ago

I'm going to try to do this tonight (trying to keep my eyes above water lol). I've deployed to meteor.com and modulus so far with no issues. If you're using MUP then you'll have to configure env vars and package.json a bit differently (it'll look for a file called package.json in the same dir as mup.json)

AdamBrodzinski commented 8 years ago

@tomitrescak I just pushed PR #59 to add support for modulus, meteor.com, mup (partially) and demeteorizer (for custom/local servers).

Once setup you can just run deploy mup and be done. Mup requires a bit of configuration compared to modulus or meteor.com deploy.

Now when you run build it will just build the web app into meteor_core, then run deploy with an argument to choose the service to deploy to (case statement needs modified for your app name).

For package.json support with MUP they need to be renames and moved into the same dir as the mup.json file, see your other issue to resolve this. Once that is done then mup willl work. So:

tomitrescak commented 8 years ago

@AdamBrodzinski looks great! Hopefully the PR will be accepted soon and I'll test it! Thanks for this!

tomitrescak commented 8 years ago

Hmm, I think you missed a cd command before deploy, otherwise mup cannot find the mup init and all

"mup" )
      echo "Make sure to mup init and mup setup before first deploy"
      # you will also need to move settings/prod.json to settings/prod/settings.json
      # then mup init inside settings/prod/ so that mup uses the new settings.json
      # this will require a settings path change in ./dev script
      cd settings/prod
      mup deploy
    ;;
rclai commented 8 years ago

If you're doing lazy-loading of styles and components, do you need to have a webpack server running on your production server too?

jedwards1211 commented 8 years ago

@rclai nope, not unless you want hot-reloading in production :)

jedwards1211 commented 8 years ago

@tomitrescak in the shelljs script now it just goes to meteor_core and calls mup deploy. But I could eventually put the settings.json paths in variables so that it's easier to move things around for mup

jedwards1211 commented 8 years ago

@rclai I don't know all the details of how lazy loading works, but I'm pretty sure that for an async require (has to be async for code splitting), the Webpack output checks that the chunk containing the required module is loaded, and if not just makes a simple ajax request for that chunk. Once that chunk is loaded it passes it to the async require callback