对CSS和JavaScript的更改仅在部署静态内容后才适用 [英] Changes to CSS and JavaScript applies only after deploying static content

查看:80
本文介绍了对CSS和JavaScript的更改仅在部署静态内容后才适用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Magento站点安装了Magento 2.我已通过以下方式激活了开发人员模式:

I installed Magento 2 from the Magento site. I have activated the developer mode by

{project directory}>php bin/magento setup:mode:set developer

然后我安装了自定义主题,最后我通过以下方式部署了静态内容

Then I have installed my custom theme and finally I deployed my static content by

{project directory}>php bin/magento setup:static-content:deploy

我的问题是我每次必须删除pub/static目录并部署静态内容才能应用css和javacript更改.静态内容部署过程很慢,并且花费大量时间,非常令人沮丧.我开发了一些东西,必须部署才能使更改出现.即使是很小的变化.刷新缓存无济于事.任何帮助,将不胜感激.预先感谢.

My problem is I have to delete pub/static directory and deploy static content every time to apply the css and javacript changes. The static content deploy process is slow and taking so much time that it is very frustrating. I develop something and have to deploy to get the change to be appeared. Even for very small change. Flushing cache is not helping. Any help would be appreciated. Thanks in advance.

推荐答案

更改CSS时,grunt作业应足以运行.

The grunt jobs should be enough to run when you change css.

因此您可以运行:

grunt exec
grunt less

或具有指定主题名称:

grunt exec:theme_name
grunt less:theme_name

core_config_data 表中检入数据库并禁用缩小字段,以使Magento在开发时不会缩小css/js.您可以使用此SQL查询来禁用这些字段:

Check in the database in core_config_data table and disable minify fields so Magento doesn't minify css / js while you develop. You can use this SQL query to disable those fields:

update core_config_data set value=0 where path in ('dev/css/minify_files', 'dev/css/merge_css_files', 'dev/js/minify_files', 'dev/js/merge_files')

这篇关于对CSS和JavaScript的更改仅在部署静态内容后才适用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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