Changes to CSS and JavaScript applies only after deploying static content

时光怂恿深爱的人放手 提交于 2019-12-13 18:38:54

问题


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

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.


回答1:


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

So you can run:

grunt exec
grunt less

Or with specified theme name:

grunt exec:theme_name
grunt less:theme_name

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')


来源:https://stackoverflow.com/questions/35033840/changes-to-css-and-javascript-applies-only-after-deploying-static-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!