YUI compressor ignore errors - yui-compressor

I'm using YUI compressor in a bash script to minify .js files, but it throws errors and outputs a 0kb .min.js file if the original contains reserved keywords like float or long.
the bash script.sh example:
yui-compressor main.js > main.min.js
As the js compiles successfully in browser, is there a way using the above syntax to tell YUI compressor to ingnore any errors and compress the files anyway?

Related

lessc Option --source-map-rootpath seems not to work

I use lessc 2.7.3. I generate css files via a makefile and use following paths
the makefile is in themes/bodensee
the css is generated in themes/bodensee/css
the less files are in themes/bodensee/less
the maps are in the same folder as the css files.
My problem is that css files misses the themes/bodensee path, so it raises a file not found on css.map files.
lessc -s less/wlb.less --clean-css="--s0 --advanced" --source-map-rootpath=themes/bodensee/ --source-map="css/wlb.css.map" css/wlb.css
The CSS file now contains `sourceMappingURL=css/wlb.css.map``The rootpath does not have any effect.
I also tried a fantasy rootpath and searched for it in the file - it does not appear anywhere. But the option is correct. When I try to missspell the option, LESS drops an error.
What am I missing?
Description of the --source-map-rootpath option from here
Specifies a rootpath that should be prepended to each of the less file paths inside the sourcemap and also to the path to the map file specified in your output css.
Because the basepath defaults to the directory of the input less file, the rootpath defaults to the path from the sourcemap output file to the base directory of the input less file.
Use this option if for instance you have a css file generated in the root on your web server but have your source less/css/map files in a different folder. So for the option above you might have
The problem was indeed related to the Clean-CSS plugin.
I now call
lessc --source-map --clean-css="--s0 --advanced" -s less/wlb.less css/wlb.css which is working.
There is a standalone clean-css program, but that does not generate sources for the Less files. It's not clear if the lessc plugin and the standalone tool are the same or different implementations but both use node.
The standalone cleancss tool removes the source map URL generated by lessc be default (did not play around with the dozens of options).
These Node tools develop very fast and manual/tutorials often are outdated. That's why my make file stopped working. Developers of that tools should really consider not to touch working parameters or features and to keep their code compatible.

How to automatically minify html files in PhpStorm/ WebStorm?

For CSS files I have created a file watcher like described in this manual. Also for JS files, see manual, which both uses the YUI Compressor
But I didn't find how to add file watchers, which minify html files (e.g. removing comments, ..). How can I automatically minify html files with PhpStorm?
I'd suggest looking at HTMLMinifier - it has CLI and thus can be set up as a file watcher, also it can be configured as Grunt task or Gulp task and executed using Grant/Gulp console

YUI Compressor - compress from one directory to another

I am on Win 7 and I want to compress my js/css files with YUI Compressor.
It uses require.js so I would like to keep the file names and folder structure same, before and after the compress.
I put the original js files into oldjs/ folder and want minified js files to be outputted into js/ folder.
Is there any way to do that?

YUI Compressor to compress all the files in a directory

I have a js folder that contains n number of javascript files (I might add/remove some files from that folder)
can I do something like that?
java -jar yuicompressor.jar dev/js/* -o dev/js/main.min.js
I want to merge all the files in that directory into a minified main.min.js but the command is not working. (if I put a file name instead of the * it works)

Does YUI compressor have support for rewriting relative paths?

The problems is that when I run YUI compressor (.NET MsBuild task) the minified css file preserves the same relative paths as in the original ones and given my content structure, this results incorrect paths to images and other resources. Does YUI have an option to configure it to rewrite this URLs? If it doesn't, are there other tools that do could help with this?