Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
clean-css install and cs file complete
Browse files Browse the repository at this point in the history
  • Loading branch information
maninzoo committed Nov 11, 2013
1 parent 8af550d commit e99152e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -32,7 +32,8 @@
"grunt-lib-contrib": "~0.6.1",
"uglify-js": "~2.4.3",
"grunt-contrib-copy": "~0.4.1",
"underscore.string": "~2.3.3"
"underscore.string": "~2.3.3",
"clean-css": "~2.0.0"
},
"devDependencies": {
"grunt-contrib-clean": "~0.4.0",
Expand Down
37 changes: 20 additions & 17 deletions tasks/websquaremin.js
Expand Up @@ -9,11 +9,12 @@
module.exports = function(grunt) {
'use strict';

var pd = require('pretty-data').pd,
helper = require('grunt-lib-contrib').init(grunt),
uglify = require('uglify-js'),
_s = require('underscore.string'),
path = require('path');
var pd = require('pretty-data').pd,
helper = require('grunt-lib-contrib').init(grunt),
uglify = require('uglify-js'),
_s = require('underscore.string'),
path = require('path'),
CleanCSS = require('clean-css');

grunt.registerMultiTask('websquaremin', 'Minify WebSquare XML', function() {
var options = this.options({
Expand Down Expand Up @@ -100,22 +101,20 @@ module.exports = function(grunt) {

max = grunt.file.read( src ) + grunt.util.normalizelf( grunt.util.linefeed );

if( fileType === 'XML' ) {
try {
try {
if( fileType === 'XML' ) {
max = max.replace( scriptRegex, function( all, g1, g2, g3 ) {
return g1 + uglify.parse( g2, {} ).print_to_string() + g3;
});
} catch( err ) {
grunt.warn( src + '\n' + err );
}

try {
min = pd.xmlmin( max, options.preserveComments );
} catch( err ) {
grunt.warn( src + '\n' + err );
} if( fileType === 'JS' ) {
min = uglify.parse( max, {} ).print_to_string(); // option 처리
} if( fileType === 'CSS' ) {
min = new CleanCSS( {} ).minify( max ); // option 처리
}
} if( fileType === 'JS' ) {
min = uglify.parse( max, {} ).print_to_string();
} catch( err ) {
grunt.warn( src + '\n' + err );
}

if( min.length < 1 ) {
Expand All @@ -136,11 +135,15 @@ module.exports = function(grunt) {
}

if( tally.xml ) {
grunt.log.write( ( tally.xml ? ', minified ' : 'Minified ' ) + tally.xml.toString().cyan + ' xmls' );
grunt.log.write( ( tally.xml ? ', minified ' : 'Minified ' ) + tally.xml.toString().cyan + ' xml' );
}

if( tally.js ) {
grunt.log.write( ( tally.js ? ', minified ' : 'Minified ' ) + tally.js.toString().cyan + ' jses' );
grunt.log.write( ( tally.js ? ', minified ' : 'Minified ' ) + tally.js.toString().cyan + ' js' );
}

if( tally.css ) {
grunt.log.write( ( tally.css ? ', minified ' : 'Minified ' ) + tally.css.toString().cyan + ' css' );
}

grunt.log.writeln();
Expand Down

0 comments on commit e99152e

Please sign in to comment.