在Magento 2中部署静态内容的更快方法?开发到直播等? [英] A faster route to deploying static content in Magento 2? Dev to Live etc?
问题描述
这是我的环境.请注意,这也是在相关的开发模式和生产模式中设置的.
This is my environment. Please note this is also set in the relevant development modes and production modes.
Dev:
https://ar.dev.loc/
https://en.dev.loc/
Live:
https://ar.site.com/
https://en.site.com/
我正在使用阿拉伯语和英语的多商店设置,并且一切正常,包括构建模块和模板构建.
I am using a multi store setup with Arabic and English and everything is working well including building modules and template building.
但是,如果我更改了更少的文件或JS文件(尽管使用grunt less或grunt watch),则必须在开发环境中运行以下命令,每次都必须在本地计算机上查看它们.>
However, if I make a change to any less file or JS file (despite using grunt less or grunt watch) I have to run the following commands on my development environment everything single time to see them on my local machine.
$ rm -rf var/cache var/page_cache var/view_preprocessed pub/static
$ mkdir pub/static
$ bin/magento setup:static-content:deploy
$ bin/magento setup:static-content:deploy ar_SA
$ grunt exec less // sometimes I leave this do this
$ grunt // I swap between these
每次都要花费很长时间来执行此过程.令人沮丧的是,我是一名快速的编码人员,并且喜欢立即在网站上看到CSS和Less,而不必等待.
This takes a long time to do this process everytime. It is frustrating as I am fast coder and like to see CSS and Less immediately on the site and not wait around.
我们团队正在执行的快速方法实际上是在pub/static
中进行更改,然后将这些更改发送给less和app/design
等,然后执行上面的过程,然后执行git.
The quick approach what our team is doing is actually making changes in pub/static
and then we ship these to less and app/design
etc and then do the process above and then git.
实时服务器几乎相同. Git pull然后是维护模式(在一个实时的ecom网站上疯狂!谁在构建M2?然后我们在上面运行命令-停机时间为45分钟)
Live server is pretty much the same. Git pull and then maintenance mode (madness on a live ecom site! Who build M2?? Then we run commands above - downtime of 45mins)
当然,必须有一种更快的方法来使我们的部署,开发和团队更好地工作,并在不停机的情况下更快地看到更改!
Surely there must be a quicker way for our deployment, development and team to work better and to see changes faster without downtime!
即使是Magento 2官方文档,您的LIVE网站也需要进入维护和停机模式才能发布内容-这不是我们的选择.首席技术官不高兴.简直荒谬.
与人们询问更快的发展的相关问题相同的问题:
Related questions with people asking about faster development same issues:
对CSS的更改并且JavaScript仅在部署静态内容之后才适用
所以我想整理所有问题并解决此问题.
So I want to collate all the issues and resolve this.
推荐答案
是的,通过执行以下步骤可以更快:
yes it can be faster by following steps :
- 更改应用目录中的js/css文件
- 现在删除pub/static文件夹中的文件格式
您可以通过以下命令在pub static中找到该文件
you can find the file in pub static by following command
find pub/static -iname yourjsfile.js
- 仅从 pub/static 文件夹 中删除您拥有更改的文件
- 确保 pub/static.htaccess 文件& pub/static.php 文件在那里
- 将文件写入权限分配给 pub 文件夹
- 现在在浏览器中点击URL.htaccess将直接部署丢失的js文件
- remove only that file in which you have changes from pub/static folder
- make sure that pub/static.htaccess file & pub/static.php file is there
- assign file write permissions to pub folder
- now hit the URL in browser .htaccess will directly deploy missing js file
pub/static中的
.htaccess使用参数 resource 将丢失的文件发送到 pub/static.php 和 pub/static.php 文件为该文件创建一个StaticResource(如果有)并进行部署.
.htaccess in pub/static send the missing files to pub/static.php with parameter resource and pub/static.php file creates an StaticResource for the file if available and deploy that.
注意:仅适用于 apache mod_rewrite
对于Nginx,您需要通过 nginx.conf.sample
For Nginx you need to configure the same via nginx.conf.sample
这篇关于在Magento 2中部署静态内容的更快方法?开发到直播等?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!