Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Jun 18, 2023. It is now read-only.
/uglifycssPublic archive

Port of YUI CSS Compressor from Java to NodeJS

License

NotificationsYou must be signed in to change notification settings

fmarcia/uglifycss

Repository files navigation

UglifyCSS is a port ofYUI Compressor toNodeJS for its CSS part. Its name is a reference to the awesomeUglifyJS but UglifyCSS is not a CSS parser. Like YUI CSS Compressor, it applies many regexp replacements. Note that aport to JavaScript is also available in the YUI Compressor repository.

UglifyCSS passes successfully the test suite of YUI compressor CSS.

Be sure to submit valid CSS to UglifyCSS or you could get weird results.

Installation

For a command line usage:

$ npm install uglifycss -g

For API usage:

$ npm install uglifycss

From Github:

$ git clone git://github.com/fmarcia/UglifyCSS.git

Command line

$ uglifycss [options] [filename] [...]> output

Options:

  • --max-line-len n adds a newline (approx.) everyn characters;0 means no newline and is the default value
  • --expand-vars expands variables; by default,@variables blocks are preserved andvar(x)s are not expanded
  • --ugly-comments removes newlines within preserved comments; by default, newlines are preserved
  • --cute-comments preserves newlines within and around preserved comments
  • --convert-urls d converts relative urls using thed directory as location target
  • --debug prints full error stack on error
  • --output f puts the result inf file

If no file name is specified, input is read from stdin.

API

2 functions are provided:

  • processString( content, options ) to process a given string
  • processFiles( [ filename1, ... ], options ) to process the concatenation of given files

Options are identical to the command line:

  • <int> maxLineLen for--max-line-len n
  • <bool> expandVars for--expand-vars
  • <bool> uglyComments for--ugly-comments
  • <bool> cuteComments for--cute-comments
  • <string> convertUrls for--convert-urls d
  • <bool> debug for--debug

Both functions return uglified css.

Example

varuglifycss=require('uglifycss');varuglified=uglifycss.processFiles(['file1','file2'],{maxLineLen:500,expandVars:true});console.log(uglified);

License

UglifyCSS is MIT licensed.


[8]ページ先頭

©2009-2025 Movatter.jp