Best way to combine and minify JS / CSS on Heroku

后端 未结 8 1286
梦谈多话
梦谈多话 2020-12-24 06:39

First of all, according to this answer, the :cache => true option on stylesheet_link_tag and javascript_include_tag doesn\'t work o

8条回答
  •  萌比男神i
    2020-12-24 07:19

    There are probably various ways to do this, but what works for me is to minify before pushing. Then I use a subtree to keep my build files separate from the "source" files. So, for example, if you build to a folder called "dist", you can push to a subtree called heroku/master like this:

    git subtree push --prefix dist heroku master
    

    Just don't forget to ensure that the dist folder is not ignored (it often is, by default) - so edit your .gitignore file accordingly.

    The --prefix command ensures that the dist folder effectively becomes the "root" folder from the point of view of that branch.

提交回复
热议问题