Comments (17)
Is java installed ?
java -version
And can you provided me some code to test ?
Thanks.
from node-minify.
Basically I have a grunt task that has this.files setup. So you end up with something like this:
this.filesforEach( function ( f ) {
var i, slen;
slen = f.src.length;
for ( i = 0; i < slen; i += 1 ) {
// pseudo filter
if ( f.src[ i ].indexOf( "min.js" ) === -1 ) {
fname = f.src[ i ].replace( /^src\//, '' );
// copy source file
grunt.file.copy( f.src[ i ], destOut + fname );
// create minified dest file
if ( minDest === '' ) {
minFileOut = destOut + fname.replace( ".js", "-min.js" );
} else {
minFileOut = minDest + fname;
}
compress( destOut + fname, minFileOut, type );
}
}
and then the compress function is below.
function compress( sourceFile, destFile, type ) {
var comp;
function errorHandler( error, min ) {
if ( error ) {
grunt.log.warn( error, min );
return;
}
grunt.log.writeln( 'File `' + destFile + '` created.' );
// Let Grunt know the asynchronous task has completed
return;
}
try {
comp = new Compressor.minify( {
'type': type,
'fileIn': sourceFile,
'fileOut': destFile,
'callback': errorHandler
} );
} catch ( e ) {
grunt.log.error( 'File `' + destFile + '` NOT created. ' + e );
}
}
from node-minify.
I tried in a simple grunt task :
module.exports = function (grunt) {
'use strict';
grunt.initConfig({
minify: {
options: {},
files: []
}
});
grunt.registerMultiTask('minify', 'compress files', function() {
var compressor = require('node-minify');
function errorHandler( error, min ) {
if ( error ) {
grunt.log.warn( error, min );
return;
}
//grunt.log.writeln( 'File `' + destFile + '` created.' );
// Let Grunt know the asynchronous task has completed
return;
}
try {
var comp = new compressor.minify( {
'type': 'yui-js',
'fileIn': 'pm.share.js',
'fileOut': 'pm.share-min.js',
'callback': errorHandler
} );
} catch ( e ) {
console.log(e);
//grunt.log.error( 'File `' + destFile + '` NOT created. ' + e );
}
});
grunt.registerTask('default', ['minify']);
};
It's working with that.
Can you give me the values of your 3 variables ? sourceFile, destFile, type
from node-minify.
type: is "yui-js"
sourceFile is a js file under src, destFile is that file copied over to target/classes
from node-minify.
Hmm I wonder if this is a mac thing? I ran your code and it does nothing on my mac.
from node-minify.
I'm on mac too.
Put that code in a Gruntfile.js
Then npm install grunt node-minify
And run "grunt".
Also change fileIn and fileOut values.
from node-minify.
Ok, I updated the plugin and yui-js still does not work, but uglifyjs does.
from node-minify.
Ok, well uglify-js works and I can mangle variable names so I will just move forward with uglify-js. Also uglify-js seems smaller with the -m option.
from node-minify.
So, this is related to java.
What version are you using ?
from node-minify.
I think java 6, but it may be 7. Does that make a difference?
from node-minify.
I tried on both, it's the same.
from node-minify.
64 or 32 bit? I have
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)
from node-minify.
64 bits for me too.
Have you try yui from the command line ?
Here an exemple :
java -jar /path/to/yuicompressor-2.4.8.jar /path/to/filetocompress.js -o /path/to/output.js --type js
You can download yui : https://github.com/yui/yuicompressor/releases
from node-minify.
Ok, I've published the plugin I am working on, it is located here: https://github.com/joseph-jja/grunt-minify-each. It works fine with uglify, but has issues with yui-js. If you want to look at it and see any issues, let me know why it might not work with yui-js.
from node-minify.
I found why it's not working in your plugin.
This is because of parameters you passed : "--max-line-len=10000 --lift-vars -m"
These are not recognized by yui compressor, but only uglifyjs.
With an empty parameters, it's ok : "parameters: []"
from node-minify.
I removed those and still it does not work for me. Must be something else on my system. Some other setting. For certain files I get messages about spawn EMFILE so I have to set ulimit each time
from node-minify.
Yes, that must be that, it's ok for me with an empty parameters.
Try to test on another system.
from node-minify.
Related Issues (20)
- CLI node-minify --option : json error HOT 1
- glob not working with cli HOT 2
- Error: ENOENT: no such file or directory HOT 3
- Update mkdirp to resolve minimist vulnerability HOT 1
- glob exclude not work HOT 1
- parse error on let = HOT 1
- Directory matching *.html in wildcard path causes uncaught error. HOT 1
- High severity security vulnerability in dependencies
- Document website cannot be visited HOT 1
- [Version 6.1.0] Error when running CLI HOT 1
- Command line error using 6.2.0 HOT 4
- Security vulnerabilities
- Security fix for @node-minify/terser
- Dependency Dashboard
- Publish recenter packages to NPM HOT 2
- Broken link in docs HOT 2
- Node-minify gets stuck at Done! without exiting HOT 4
- direct input HOT 3
- Coments HOT 1
- Suggestion: JSON minifier? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-minify.