3

I'm using Yeoman to generate out an angular app. Once I'm happy with my app, I run grunt which creates a production-ready version of my application in a folder called /dist at the root of my project.

I've then initialised this /dist directory as a Git repository with git init and pushed the files up to Bitbucket, where they currently sit right now.

What I'm asking is do I have to compile my production-ready app with grunt every time I want to make a commit? It seems I have to. I'm thinking this setup might not be the most productive way to do this?

Am I missing something, is there an easier and more productive way to handling this?

realph
  • 4,481
  • 13
  • 49
  • 104
  • 2
    Basically, you are checking the wrong thing into git. Your main application in the root directory is what you actually want to share and collab on with other people. The /dist directory is for exactly what you said, pushing to production where performance, etc matters most. You can make /dist a git repo but it's only purpose should basically be pushing to your production server. Every other commit during development should be done on your apps root repo. Also, you can't collab with people if you only use /dist because that is the "packed" version of your app – tommybananas Dec 08 '14 at 16:20
  • @snowman4415 Would you need to make two repos, or a repo within a repo (root folder and /dist)? Could you explain the best way to handle something like this? – realph Dec 08 '14 at 17:03

1 Answers1

3

That workflow is odd.

Only source code should be in your git repository. Not the compiled/minified files. Source code is what matters.

When you colaborate with somebody else, they should run grunt tasks on their own.

Dist package should be created before deploy to production. Or on regular basis by the continuous integration server.

  • Yeah, it felt odd. Say I push the entire root repo to Bitbucket, is there a way to just pull down just the `/dist` directory onto the server? Or is it worth putting the entire repo on my web server, and pointing the site to my `/dist` folder? Sorry for the silly question. – realph Dec 08 '14 at 22:50
  • I suppose you are trying to do some kind of "git deploy". According to: http://stackoverflow.com/questions/10124223/pulling-just-one-directory-out-of-a-git-repo Its possible to checkout single directory. But still you shouldnt commit compiled dist directory into your repository. its odd, and application will became fragile, because when you fix some bug and dont run build manualy, your dist is not updated. So ... I would suggest to forget about that thing. And rather think about deploy script, which will provide atomic deploy - 1.pulls current version, 2.run build 3.copy dist to the server – Víťa Plšek - angular.cz Dec 08 '14 at 23:00
  • Do you know where I can get some information about a deploy script like that? I assumed such a generator like Yeoman, would have an easy option to deploy the finished app via Git. – realph Dec 08 '14 at 23:34
  • I write these scripts on my own. I don't use git for deploy. For me its just scipt "deploy.sh" where I basicly do pull to tmp, gulp build, and then rsync /dist to production server via ssh. – Víťa Plšek - angular.cz Dec 09 '14 at 08:44