简体   繁体   English

合并我的CSS和JS文件会破坏代码(在Mac上工作,而不是在我的服务器上工作)

[英]merging my CSS and JS files breaks code (working on mac, not on my server)

I'm merging (and afterwards minify with YUI compressor) my CSS and JS files. 我正在合并(然后使用YUI压缩器最小化)我的CSS和JS文件。 My web application works fine when just linking the separate files. 仅链接单独的文件时,我的Web应用程序运行良好。

Now I want to merge the files as one CSS file, so I just basically do the following: 现在,我想将这些文件合并为一个CSS文件,因此我基本上只需要执行以下操作:

find /myapp/js/ -type f -name "incl_*.js" -exec cat {} + > ./temporary/js_backend_merged.js 查找/ myapp / js / -type f -name“ incl _ *。js” -exec cat {} +> ./temporary/js_backend_merged.js

That merges all my javascript files perfectly. 那完美地合并了我所有的javascript文件。 When I do this on my mac, all goes well and I can use the merged file in my application with no problems 当我在Mac上执行此操作时,一切顺利,并且可以在应用程序中毫无问题地使用合并的文件

When I merge the same files with the same command on my CentOS server, this doesn't work, my JS start throwing errors. 当我在CentOS服务器上用相同的命令合并相同的文件时,这不起作用,我的JS开始抛出错误。 I have the same problem when merging CSS files, the CSS doesn't render correctly on my Centos box when merged. 合并CSS文件时,我有同样的问题,合并后CSS在我的Centos框上无法正确呈现。 It does when I merge them on my MAC. 当我在我的MAC上合并它们时,它会执行此操作。

Also, I did the same process before on my previous centos server, with no problems at all. 另外,我之前在以前的centos服务器上执行了相同的过程,完全没有问题。

I'm thinking in the direct of a character set problem on the server maybe? 我正在考虑直接在服务器上出现字符集问题? Who can solve this little mistery that took 2 complete days of my time already with no luck at all... 谁能解决这只花了我整整2天时间的运气,一点运气都没有...

UPDATE: the problem is that the command: find /myapp/js/ -type f -name "incl_*.js" -exec cat {} + > ./temporary/js_backend_merged.js orders files from incl_01 to incl_02, ... correctly on the mac, but the same command orders these files differently on the server 更新:问题是该命令:查找/ myapp / js / -type f -name“ incl _ *。js” -exec cat {} +> ./temporary/js_backend_merged.js将文件从incl_01排序为incl_02,...在Mac上正确显示,但同一命令在服务器上对这些文件的排序不同

I see that I can use sort -n to sort results, but I cant get the above command working correctly with the sort option added to it. 我看到我可以使用sort -n对结果进行排序,但是我无法使上面的命令与添加到其中的sort选项一起正常工作。

(find /myapp/js/ -type f -name "incl_*.js" | sort | xargs cat) > ./temporary/js_backend_merged.js

That'll use find the list of files, sort them, then pipe to xargs, takes the list of files from stdin, and applies the 'cat' command to them. 这将用于查找文件列表,对其进行排序,然后通过管道传输到xargs,从stdin中获取文件列表,然后对它们应用“ cat”命令。

Then the whole thing is redirected to js_backend_merged.js 然后将整个内容重定向到js_backend_merged.js

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

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