Git:存储但不拉动LESS文件 [英] Git: Storing but not pulling LESS files

查看:189
本文介绍了Git:存储但不拉动LESS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始与LESS合作,正如我对Jenkins和Grunt这样的自动化构建者进行了一些研究,似乎常见的一条建议并不是将LESS文件存储在回购站中,或者不要将它们放在实时服务器上,只是编译好的CSS。



所以我希望得到一些建议。看起来LESS文件是该项目的一部分,因此存储它们是必要的。但有意义的是不要在活动服务器上有额外的随机文件。删除他们自己似乎是每个构建都做的错误方式,而且耗时。我想我可以让自动化的建设者为我做,虽然我还不知道如何。最直接的方法似乎是不要把它们放在首位。



或者我在考虑以错误的方式回购?我应该有不同的文件存储介质来存储LESS文件和其他文件吗?我已经不把我的PDF存储在回购协议上了,我应该将LESS视为相同吗?我应该如何存储这些文件?

解决方案

冲突来自聚合源管理和发布管理:您使用的是相同的引用:
$ b


  • 存储源代码(您可以在其中构建版本,包含已编译的CSS文件),
  • 部署(发布过程的一部分)


文章使用git的理想LESS工作流程提出了一个预提交钩子以确保css始终保持同步但是这意味着将生成的内容存储在git仓库中。



我宁可:


  • 推送到裸露的回购

  • 有一个post-receive挂钩,它会:

    • 在目标文件夹(实时网站)中

    • 构建编译的css(使用lessc压缩) 删除所有文件s文件



I recently started working with LESS, and as I did some research to automated builders like Jenkins and Grunt, it seemed a common piece of advice was not to store LESS files on the repo, or not to have them on the live server, just the compiled CSS.

So I was hoping to get some advice on this. It seems that as LESS files are part of the project, storing them is necessary. But it makes sense not to have extra, random files on the live server. Deleting them myself seems the wrong way to do it every build, plus time consuming. I assume I can get automated builders to do it for me, though I don't yet know how. The most straight forward way would seem to be to not pull them down in the first place.

Or am I thinking about repos the wrong way? Should I have a different file storage medium for storing the LESS files, and others? I already don't store my PDFs on the repo, should I treat LESS the same? How should I store these files?

解决方案

The conflict comes from aggregating source management and release management: you are using the same referential to:

  • store sources (from which you can build releases, included the compiled CSS files),
  • and to deploy (part of the release process)

The article "The Ideal LESS Workflow with git" suggests a pre-commit hook to make sure the css are always in sync with LESS changes, but that means storing generated content in the git repo itself.

I would rather:

  • push to a bare repo
  • have a post-receive hook which would:
    • checkout that bare repo in the target folder (the live site)
    • build the compiled css (compressed with lessc)
    • remove all less files

这篇关于Git:存储但不拉动LESS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆