简体   繁体   English

symfony2中的反向工程师CSS和JS文件

[英]Reverse engineer css & js files in symfony2

In symfony2 there are compiled and uncompiled css/js files i did not knew that. 在symfony2中,有我不知道的已编译和未编译的css / js文件。 So we made changes to file directly under web/css and web/js folder. 因此,我们直接在web / css和web / js文件夹下对文件进行了更改。 Now i am having trouble as to how to move the files to uncompiled files that is files under asset folders. 现在,我在如何将文件移动到未编译文件(资产文件夹下的文件)时遇到了麻烦。

So i cannot run this command now: php app/console assetic:dump --env=prod --no-debug which will re-create all css and js files under web folder and we will loose all our changes. 所以我现在不能运行此命令:php app / console assetic:dump --env = prod --no-debug,它将重新创建Web文件夹下的所有CSS和JS文件,我们将放弃所有更改。

Is there any command or way to reverse this? 有什么命令或方法可以扭转这种情况吗? Like move our changes from web/css or web/js folder to assets with one go rather than hand picking them? 像一口气将我们的更改从web / css或web / js文件夹移动到资产,而不是手动挑选它们吗?

A way to do it would be to backup your web/css and web/js folders, then run php app/console assetic:dump --env=prod --no-debug again. 一种方法是备份您的web / css和web / js文件夹,然后运行php app/console assetic:dump --env=prod --no-debug

This way, you will have the version with changes (in the back-up) and without in web/css and web/js. 这样,您将拥有带有更改的版本(在备份中),而没有在web / css和web / js中。

Then via a diff command on your server, you would be able to spot the changes you have to move manually back to the assets. 然后,通过服务器上的diff命令,您将能够发现必须手动移回资产的更改。

If you are on a production site and really need this operation to go quickly you can do this : 如果您在生产现场并且确实需要快速执行此操作,则可以执行以下操作:
The first four commands are just to have a back up of the actual state. 前四个命令只是要备份实际状态。 Then the rest is to recreate the assets as they should be and save those in a folder to compare them later on then reinstate the back up where your manual changes are so the people browsing your site won't hopefully have the time to notice anything. 然后剩下的就是按原样重新创建资产,然后将其保存在文件夹中以供日后比较,然后恢复手动更改所在的备份,这样浏览您网站的人就没有时间注意到任何东西。

cd web
cp -R js js.bk
cp -R css css.bk
cd .. 
php app/console assetic:dump --env=prod --no-debug && cd web && cp -R js js.clean && cp -R css css.clean && rm -R css && cp -R css.bk css && rm -R js && cp -R js.bk js

Then you can compare the folders .bk against le folders .clean 然后,您可以将.bk文件夹与.clean文件夹进行比较

diff css.clean css.bk
diff js.clean js.bk

And readjust your changes on the right assets 并重新调整对正确资产的更改

A dummy example of a diff result : 差异结果的虚拟示例:

bash$ diff a b
diff a/test.css b/test.css
1c1
< .a { color:#321; }
---
> .a { color:#123; }

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

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