How to prepare for deployment to production
Opened this issue · 5 comments
I don't see a reference in the readme that explicitly describes building a production ready project. That is, concatenating and uglifying js and css files, and otherwise copying all project files such that /dist can be zipped up and deployed to a production server.
I have been able to get js copied to /dist and uglified by editing /Gruntfile.js and setting:
options: {
// `name` and `out` is set by grunt-usemin
baseUrl: 'app/scripts',
optimize: 'uglify',
dir: 'dist',
paths: {
'templates': '../../.tmp/scripts/templates'
},
Then running
grunt requirejs:dist
The result is that all js files are copied (not concatenated) to /dist and uglified, but no other application files are copied to the /dist folder.
What am I missing?
You need to run grunt build
. No need to modify anything in the Gruntfile.js.
grunt build
works great yet i'm still experiencing some confusion on what to do once it's built. i confess this is my first real go with grunt scripts so if someone could please take a moment to slow it down and step me through the commands after grunt build
i would greatly appreciate it.
After that you need to upload the content of the dist
folder to your server. That's it.
Excellent!
Thank you for the quick reply. Now if i may take advantage of your generous help... i'm working with aws and have been able to bet a few instances running nicely behind a load balancer etc etc. Do you have any recommendations on how to deploy said dist
folder? Currently I am pushing and pulling from git but of course this will not scale and is unadvised for many reasons.
If you could point me to a grunt script or tutorial etc etc I could probably take it from there.
Thanks again for the help greatly appreciated. Sometimes it takes a village ;)
Well, the code for the browser you should put it on S3, not in EC2. S3 is a CDN which is where you want to have your assets. To do that you can use grunt-s3-sync
. If you also are using the express application then you do need to put it on your EC2 instances, for that you can do sftp: grunt-ssh
or grunt-sftp-deploy
.
Googling really quick I came up with this article that may help you: http://tech.toptable.co.uk/blog/2013/08/08/grunt-your-deployments-too/
Hope that helps.