Code Monkey home page Code Monkey logo

compresser's Introduction

借助于Sublime Text和Uglify实现程序自动压缩脚本 Build Status

使用步骤如下:

  • 一、Uglify压缩脚本安装

    1. 安装nodeJS并配置环境变量
    2. 新建目录sampleFolder
    3. 把compress.js放入sampleFolder
    4. 在sampleFolder中新建目录node_modules
    5. 把node_modules里的uglify-js、colors和node-css-compressor复制到node_modules下
  • 二、配置Sublime Text插件

    1. 把 ./uglify.py放在Sublime Text的安装目录/Data/Packages/Default/下
    2. 修改./uglify.py,配置相应参数
    3. 重启Sublime Text,在用户保存文件时就可以自动压缩脚本

compress.js用法

node compress.js [sourceFilePath] [miniFilePath] [--colors=[true|false]]

  • node compress.js /source-path (压缩指定目录到默认目录)
  • node compress.js /source-path /target-path (压缩指定目录)
  • node compress.js /data/js-source/test.js (压缩指定目录到默认目录)
  • node compress.js /data/js-source/test.js /data/js/test.js (压缩指定文件)

#### miniFilePath为空时的生成规则 1.首先会把目录中的-source替换掉(只替换目录,不替换文件名), 如:/a/js-source -> /a/js,a/js-source/b.js -> a/js/b.js 2.如果生成的目标目录和原目录相同 * 如果是目录直接在源目录后加 "-min", 如:/a/js -> /a/js-min,/a/css -> a/css-min * 如果是文件把文件名后加 "-min", 如:/a/js/a.js -> /a/js/a-min.js,/a/css/a.css -> /a/css/a-min.css

##node版本升级造成脚本运行异常   由于node升级造成脚本运行异常,node 0.7+以上把path.exists和path.existsSync迁移到了fs模块里, 所以会报出警告,这时sublime得到的输出结果有异常,导致整个脚本不会运行结果不对,请更新compress.js。

后续再加入相应文档

compresser's People

Contributors

tonny-zhang avatar

Watchers

James Cloos avatar  avatar

Forkers

fc13240

compresser's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.