https://github.com/zweifisch/ccjs
client-side common js
https://github.com/zweifisch/ccjs
Last synced: 2 months ago
JSON representation
client-side common js
- Host: GitHub
- URL: https://github.com/zweifisch/ccjs
- Owner: zweifisch
- License: mit
- Created: 2014-04-01T12:51:37.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-11-28T10:49:24.000Z (over 10 years ago)
- Last Synced: 2025-08-09T02:56:59.482Z (11 months ago)
- Language: JavaScript
- Size: 83 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ccjs
client-side common js
## how does it work
* it will be used as a middlare(described below) inside your connect based
application(e.g. express)
* when the browser make a request to the server asking for a js file, the
original js file will be read from disk, and all dependencies of that file
get bundled and sent to browser
* for performance consideration, the js file need to be pre-bundled for
deployment, this can be done using
[grunt-ccjs](https://github.com/zweifisch/grunt-ccjs)
## limitations
* only works with packages that has little to do with node, like jquery and lodash
* `require` takes place on the server side, so dynamic require won't work
## usage
### using the middleware
see `tests/server.js`
```javascript
var path = require('path');
var ccjs = require('ccjs').middleware;
app.use(ccjs({root:path.join(__dirname, '/public/js')}));
```
```html
```
### coffeescript
```sh
npm install --save coffee-script
```
```coffee
app.use ccjs
root: path.join __dirname, '/public/js'
coffee: on
```
### grunt plugin
* [grunt-ccjs](https://github.com/zweifisch/grunt-ccjs)