Code Monkey home page Code Monkey logo

e-combo's Introduction

e-combo

一个基于node的combo服务器,主要用来练手。

Getting Started

首先,checkout当前项目的代码。

git clone https://github.com/chyingp/e-combo

进入项目根路径,安装相关依赖。

npm install

可以看到,主要依赖了expresscssminuglifyjs三个模块。

adeMacBook-Pro-3:node_modules a$ tree -L 1
.
├── cssmin
├── express
└── uglify-js

运行下面命令,启动服务,默认是采用端口3000。

node index.js

接着,在浏览器里访问 http://127.0.0.1:3000/c/=/require.js,jquery.js ,就会看到合压缩合并后的require.js,jquery.js

URL配置参数

目前只在URL里暴露了两个参数,分别是max-agecompress

  • max-age:静态资源缓存的时间。如果没有传,则不设置。
  • compress:是否压缩返回结果。默认为是。

例子:http://127.0.0.1:3000/c/=/require.js,jquery.js?max-age=3000&compress=0 。将缓存时间设置为3000s,同时返回结果不压缩。

规则解释

规则比较简单。从上面的例子可以看到,访问combo服务的URL主要由两部分组成。

  • http://127.0.0.1:3000/c/=/:服务器会将/c/=/开头的资源请求,转发到combo服务。
  • require.js,jquery.js:需要合并请求的资源文件,路径相对于public目录。

同理,假设现在要访问a.jsb.jsc.js合并输出后的文件,只需要按照上面的规则进行拼装:

http://127.0.0.1:3000/c/=/a.js,b.js,c.js

其他

由于是练手用的,日志记录、容错处理、性能优化等都没有考虑。

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.