[英]Version control strategy for webpack-encore project
I'm learning to use webpack-encore and noticed it is installed only as a dev
dependency. 我正在学习使用webpack-encore,并且注意到它仅作为
dev
依赖项安装。 Does that mean I should compile my js
and css
files on development and push them to the repository, and then to production? 这是否意味着我应该在开发时编译我的
js
和css
文件,并将它们推送到存储库,然后再推送到生产环境?
That seems to me what the docs are implying, but wouldn't that mean a merge-conflict hell? 在我看来,这意味着文档所隐含的含义,但这是否意味着合并冲突地狱? Compiled files would be impossible to merge.
编译的文件将无法合并。
Also wouldn't that be contrary to version control philosophy? 也不会违背版本控制原则吗? As far as I know, you don't publish binaries in compiled languages (ie C/C++), you push the code and expect the server to compile them.
据我所知,您不会以编译语言(即C / C ++)发布二进制文件,而是会推送代码并期望服务器对其进行编译。 I know this isn't the same type of "compilation" in javascript, but what is the expected behavior of the production server in this case?
我知道这与javascript中的“编译”类型不同,但是在这种情况下生产服务器的预期行为是什么? To receive the files ready to serve them, or to compile them at the time of release?
要接收准备服务的文件,还是在发布时进行编译?
Thanks in advance 提前致谢
Does that mean I should compile my js and css files on development and push them to the repository, and then to production?
这是否意味着我应该在开发时编译我的js和css文件,并将它们推送到存储库,然后再推送到生产环境?
Not exactly - it depends on how you deploy. 不完全是-这取决于您的部署方式。
When you deploy, you need to run ./node_modules/.bin/encore production
to build your assets. 部署时,需要运行
./node_modules/.bin/encore production
以构建资产。 Once you've done this, only your built assets (eg web/build
) need to be transferred to production. 完成此操作后, 仅需要将已构建的资产(例如
web/build
)转移到生产中。
You could run this command locally (or on some "build" server) and the transfer all the files to production. 您可以在本地(或在某些“构建”服务器上)运行此命令,并将所有文件传输到生产环境。 Or, you could use a
git pull
on production, and then run this command on production (the downside being that you would need Node.js installed on production). 或者,您可以在生产环境中使用
git pull
,然后在生产环境中运行此命令(不利之处是您需要在生产环境中安装Node.js)。
You shouldn't / don't need to commit your built files to your repository. 您不需要/不需要将构建的文件提交到存储库。 But... if it simplifies your deploy (ie you want to do a
git pull
and be done), there's no real problem with that. 但是...如果它简化了您的部署(即您要进行
git pull
并完成),则没有任何实际问题。
I just added a PR to answer these in the FAQ ( http://symfony.com/doc/current/frontend/encore/faq.html ) - here's the PR until it's deployed: https://github.com/symfony/symfony-docs/pull/8109 我只是在FAQ( http://symfony.com/doc/current/frontend/encore/faq.html )中添加了PR来回答这些问题-这是部署之前的PR: https : //github.com/symfony/ symfony-docs / pull / 8109
Cheers! 干杯!
Solution 1: 解决方案1:
yarn run encore production
locally yarn run encore production
Solution 2: 解决方案2:
yarn run encore production
remotely during deployment yarn run encore production
To my eyes the 2nd solution is way better, because you don't need an extra human-checking before deployment, everything is automated. 在我看来,第二种解决方案更好,因为在部署之前不需要额外的人工检查,一切都是自动化的。 But this has a strong drawback: building assets can be a slow process, and when I deploy, my production is down during 5 to 20 seconds until assets are built.
但这有一个很大的缺点:资产的建立过程可能很慢,而当我部署时,在资产建立之前,我的生产会在5到20秒内停机。
Here's the HTTP 500 error: 这是HTTP 500错误:
An exception has been thrown during the rendering of a template ("Asset manifest file "[...]/web/build/manifest.json" does not exist.").
呈现模板期间引发了异常(“资产清单文件“ [...] / web / build / manifest.json”不存在。”)。
It looks like the manifest.json
file is deleted at the beginning of the process, and created from scratch later on. 看起来
manifest.json
文件在该过程的开始被删除,并在以后从头开始创建。
Something that should be improved? 有什么需要改进的地方吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.