简体   繁体   中英

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. My web application works fine when just linking the separate files.

Now I want to merge the files as one CSS file, so I just basically do the following:

find /myapp/js/ -type f -name "incl_*.js" -exec cat {} + > ./temporary/js_backend_merged.js

That merges all my javascript files perfectly. When I do this on my mac, all goes well and I can use the merged file in my application with no problems

When I merge the same files with the same command on my CentOS server, this doesn't work, my JS start throwing errors. I have the same problem when merging CSS files, the CSS doesn't render correctly on my Centos box when merged. It does when I merge them on my MAC.

Also, I did the same process before on my previous centos server, with no problems at all.

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...

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

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.

(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.

Then the whole thing is redirected to js_backend_merged.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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