简体   繁体   English

go buffalo 工作流中的 /public/assets 在哪里生成?

[英]Where are /public/assets generated in the go buffalo workflow?

In go buffalo, there is a generated .gitignore file which ignores public/assets.在 go buffalo 中,生成了一个忽略公共/资产的 .gitignore 文件。 However, at the same time, the generated css and js are critical for getting a 'real' buffalo app.但是,与此同时,生成的 css 和 js 对于获得“真正的”buffalo 应用程序至关重要。 So, there's a disconnect which I don't fully understand, which is that something seemingly critical for deploying an app is bound to be missing, by default, from any version control system which builds the app itself.因此,有一个我不完全理解的脱节,即默认情况下,任何构建应用程序本身的版本控制系统都必然会缺少对部署应用程序来说看似至关重要的东西。

What I've noticed我注意到的

  • buffalo build does not generate content in public/assets. buffalo build 不会在公共/资产中生成内容。

  • buffalo dev also does not generate this content. buffalo dev 也不生成此内容。

  • running buffalo dev after deleting public/assets/* results in a site that doesn't have any CSS, implying that it breaks functionality.在删除public/assets/*后运行 buffalo dev 会导致站点没有任何 CSS,这意味着它破坏了功能。

So, thus.所以,这样。 from what I can tell /public/assets are both essential, and non-dynamically created.据我所知, /public/assets 既是必不可少的,又是非动态创建的。

So, my question is thus, how can i regenerate public/assets in my buffalo workflow at build time (ie how can i retain the .gitignore defaults) or where do people generally package their assets if not in version control?所以,我的问题是,如何在构建时在我的水牛工作流中重新生成公共/资产(即我如何保留 .gitignore 默认值)或者如果没有版本控制,人们通常在哪里打包他们的资产?

So to answer the original question of where public/assets are generated - the answer is "at creation time" or "at build time, if you dont have them, and if you bootstrap the empty directory".因此,要回答公共/资产在哪里生成的原始问题 - 答案是“在创建时”或“在构建时,如果您没有它们,并且您引导空目录”。 Hopefully after the PR mentioned below is merged, the answer to this question will be "at creation time, or at build time if they don't already exist in your repo (ie because they are gitignored)".希望在合并下面提到的 PR 之后,这个问题的答案将是“在创建时,或者在构建时,如果它们不存在于您的存储库中(即因为它们被 gitignored)”。

The two points (why local build doesnt generate them + why docker build doesnt generate them) have completely unrelated and different answers, so I'll treat them each in separate bullets.这两点(为什么本地构建不生成它们 + 为什么 docker build 不生成它们)有完全不相关和不同的答案,所以我将分别对待它们。

  • We've found that actually, depending on the state of your repository, if you lose/delete the webpack files, the buffalo environment doesn't regenerate them for you, and thats not a bug in anyway, because its a valid use case to run buffalo without generating any assets (although this is not a use case which seems very useful to me, it might be worth proposing a change to make buffalo more opinionated in this regard).我们发现实际上,根据存储库的状态,如果您丢失/删除了 webpack 文件,buffalo 环境不会为您重新生成它们,无论如何这都不是错误,因为它是一个有效的用例在不生成任何资产的情况下运行 buffalo(尽管这不是一个对我来说似乎非常有用的用例,但可能值得提出更改以使 buffalo 在这方面更加自以为是)。

  • Regarding the docker build itself, it seems that if you add a mkdir statement to ensure that public/assets exists before running buffalo build (ie in your Dockerfile), then you can compensate for the fact that you are git-ignoring that directory, and it will correctly be populated in the static build.关于 docker build 本身,似乎如果您运行 buffalo build之前添加mkdir语句以确保 public/assets 存在(即在您的 Dockerfile 中),那么您可以补偿您忽略该目录的事实,并且它将在静态构建中正确填充。

Since the latter use case is the more important one, I've created a pull request to address this issue (ie to make it so that you don't need to manually add a mkdir public/assets step) under the guidance of the buffalo community, which can be found here: https://github.com/gobuffalo/buffalo/pull/1447 .由于后一个用例更重要,因此我在 buffalo 的指导下创建了一个 pull request 来解决这个问题(即使它不需要手动添加 mkdir public/assets 步骤)社区,可以在这里找到: https : //github.com/gobuffalo/buffalo/pull/1447

In short : Until this PR merges, if you need your assets to build your deployables (which you probably do), either remove the public/assets line from gitignore and commit them to version control so that your code can directly be built with no external dependencies, OR just make sure you build your code in the same place that you run buffalo dev.简而言之:在这个 PR 合并之前,如果你需要你的资产来构建你的可部署物(你可能会这样做),要么从 gitignore 中删除 public/assets 行并将它们提交给版本控制,这样你的代码就可以直接构建而无需外部依赖项,或者只需确保在运行 buffalo dev 的同一位置构建代码。 If there is a third answer.如果有第三个答案。 The former is the more cloud friendly solution from my perspective, but I'm new to buffalo so I may be misunderstanding the idioms in some ways.从我的角度来看,前者是对云更友好的解决方案,但我是 buffalo 的新手,所以我可能会在某些方面误解这些习语。

Disclaimer: I'm answering this question because I think it might be useful to folks, but I'm not a buffalo expert.免责声明:我回答这个问题是因为我认为它可能对人们有用,但我不是水牛专家。 There are much deeper technical perspectives on how assets work on the buffalo docs/website ( https://gobuffalo.io/en/docs/assets )关于资产如何在 buffalo docs/website ( https://gobuffalo.io/en/docs/assets ) 上工作,有更深入的技术观点

There's source control, which contains the source you've created for your application, there's the build server, which turns the source into deployable artifact(s), and there's artifacts, which contain everything necessary to run the app (ie resources, compiled binary, no source code).有源代码控制,其中包含您为应用程序创建的源,有构建服务器,它将源转换为可部署的工件,还有工件,其中包含运行应用程序所需的一切(即资源、编译后的二进制文件) ,无源代码)。

Source control is generally a poor solution for storing artifacts;源代码控制通常是存储工件的糟糕解决方案; this is why eg GitHub has the Releases feature.这就是为什么例如 GitHub 具有发布功能的原因。 Find a proper solution for your artifacts, outside of source control - what you choose will depend on your build and operating environments and your deployment system.在源代码控制之外为您的工件找到合适的解决方案 - 您的选择将取决于您的构建和操作环境以及您的部署系统。 For example, S3 is a popular choice for storing internal build artifacts because it's very easy to use and reasonably cheap.例如,S3 是用于存储内部构建工件的流行选择,因为它非常易于使用且价格合理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM