forked from ladjs/express-cdn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.json
More file actions
116 lines (116 loc) · 18.2 KB
/
package.json
File metadata and controls
116 lines (116 loc) · 18.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{
"name": "express-cdn",
"description": "Node.js module for delivering optimized, minified, mangled, gzipped, and CDN-hosted assets in Express using S3 and CloudFront.",
"version": "0.1.7",
"author": {
"name": "Nick Baugh",
"email": "niftylettuce@gmail.com"
},
"contributors": [
{
"name": "Nick Baugh",
"email": "niftylettuce@gmail.com"
},
{
"name": "Daniel Santiago"
},
{
"name": "James Wyse",
"email": "james@jameswyse.net"
},
{
"name": "Jon Keating",
"email": "jon@licq.org"
},
{
"name": "Andrew de Andrade",
"email": "andrew@deandrade.com.br"
},
{
"name": "Joshua Gross",
"email": "josh@spandex.io"
},
{
"name": "Dominik Lessel",
"email": "info@rocketeleven.com"
},
{
"name": "Elad Ben-Israel",
"email": "elad.benisrael@gmail.com"
},
{
"name": "Mateusz Wielgos",
"email": "wielgosm@gmail.com"
},
{
"name": "Aleksey Smolenchuk",
"email": "lxe@lxe.co"
},
{
"name": "David Staley",
"email": "Dstaley234@gmail.com"
}
],
"keywords": [
"express-cdn",
"cdn",
"assets",
"cloudfront",
"s3",
"amazon",
"minify",
"mangle",
"obfuscate",
"optipng",
"jpegtran",
"optimize",
"gzip",
"zlib",
"express",
"uglify"
],
"homepage": "https://github.com/niftylettuce/express-cdn",
"repository": {
"type": "git",
"url": "https://github.com/niftylettuce/express-cdn.git"
},
"engines": {
"node": ">= 0.6.0"
},
"main": "lib/main.js",
"devDependencies": {
"express": "~2.5.11",
"ejs": "~0.7.2",
"jade": "~0.26.3",
"mime": "~1.2.6",
"underscore": "~1.3.3",
"knox": "~0.8.0",
"walk": "~2.2.1",
"async": "~0.2.9",
"request": "~2.16.6",
"uglify-js": "~2.4.3",
"underscore.string": "~2.3.1"
},
"dependencies": {
"mime": "~1.2.6",
"underscore": "~1.3.3",
"walk": "~2.2.1",
"async": "~0.2.9",
"uglify-js": "~2.4.3",
"optipng-bin": "~0.3",
"jpegtran-bin": "~0.2.1",
"knox": "~0.8.7",
"request": "~2.16.6",
"underscore.string": "~2.3.1",
"clean-css":"2.0.2"
},
"readme": "\n# express-cdn <sup>[](https://npmjs.org/package/express-cdn)</sup>\n\nNode.js module for delivering optimized, minified, mangled, gzipped, and CDN-hosted assets in Express (currently by Amazon S3 and Amazon CloudFront).\n\nView these docs generated with [readme-docs](https://github.com/getprove/node-bootstrap-readme-docs) here:\n<http://niftylettuce.github.io/express-cdn>\n\nFollow [@niftylettuce](http://twitter.com/niftylettuce) on Twitter for updates.\n\nLike this module? Check out [node-email-templates](https://github.com/niftylettuce/node-email-templates)!\n\n\n## Index\n\n- [Features](#features)\n- [Add-On Modules](#add-on-modules)\n- [How Does It Work?](#how-does-it-work)\n- [Environment Differences](#environment-differences)\n- [CDN Setup Instructions](#cdn-setup-instructions)\n- [Quick Start](#quick-start)\n- [Custom Logging](#custom-logging)\n- [Lazyweb Requests](#lazyweb-requests)\n- [Changelog](#changelog)\n- [Contributors](#contributors)\n- [License](#license)\n\n\n## Features\n\n* Automatic parsing of `background`, `background-image` and `content` for `url({{absoluteUrl}})` in stylesheets and scripts.\n* Built-in optimization of images in production mode using binaries from NPM of [OptiPNG][1] and [JPEGTran][2].\n* Supports [Sass][3], [LESS][4], and [Stylus][5] using respective stylesheet compilers.\n* JavaScript assets are mangled and minified using [UglifyJS][6].\n* Automatic detection of asset changes and will only upload changed assets to S3 in production mode.\n* Utilizes cachebusting, which is inspired by [express-cachebuster][7] and [h5bp][8].\n* All assets are compressed using [zlib][9] into a gzip buffer for S3 uploading with `Content-Encoding` header set to `gzip`.\n* Embed multiple assets as a single `<script>` or `<link>` tag using the built-in dynamic view helper.\n* Loads and processes assets per view (allowing you to minimize client HTTP requests).\n* Combine commonly used assets together using a simple array argument.\n* Uploads changed assets automatically and asynchronously to Amazon S3 (only in production mode) using [knox][10].\n\n\n## Add-on Modules\n\nThese modules are a work in progress.\n\n* [express-cdn-cloudfront][13] - Amazon S3 and Amazon CloudFront\n* [express-cdn-maxcdn][14] - MaxCDN and Amazon S3\n* [express-cdn-cloudfiles][15] - Rackspace CloudFiles\n* [express-cdn-cloudflare][16] - CloudFlare and Amazon S3\n\n\n## How does it work?\n\nWhen the server is first started, the module returns a view helper depending on\nthe server environment (production or development). It also recursively\nsearches through your `viewsDir` for any views containing instances of the\n`CDN(...)` view helper. After parsing each instance and removing duplicates,\nit will use your S3 credentials to upload a new copy of the production-quality\nassets. Enjoy **:)**.\n\n\n## Environment Differences\n\n**Development Mode:**\n\nAssets are untouched, cachebusted, and delivered as typical local files for rapid development.\n\n**Production Mode:**\n\nAssets are optimized, minified, mangled, gzipped, delivered by Amazon CloudFront CDN, and hosted from Amazon S3.\n\n\n## CDN Setup Instructions\n\n1. Visit <https://console.aws.amazon.com/s3/home> and click **Create Bucket**.\n * Bucket Name: `bucket-name`\n * Region: `US Standard` (use `options.endpoint`\n with `'bucket.s3-xxx.amazonaws.com'` for non `US Standard` regions)\n2. Upload <a href=\"https://raw.github.com/niftylettuce/express-cdn/master/index.html\">index.html</a> to your new bucket (this will serve as a placeholder in case someone accesses <http://cdn.your-site.com/>).\n3. Select `index.html` in the Objects and Folders view from your S3 console and click **Actions → Make Public**.\n4. Visit <https://console.aws.amazon.com/cloudfront/home> and click **Create Distribution**.\n * Choose an origin:\n - Origin Domain Name: `bucket-name.s3.amazonaws.com`\n - Origin ID: `S3-bucket-name`\n * Create default behavior:\n - Path Pattern: `Default (*)`\n - Origin: `S3-bucket-name`\n - Viewer Protocol Policy: `HTTP and HTTPS`\n - Object Caching: `Use Origin Cache Headers`\n - Forward Query String: `No (Improves Caching)`\n * Distribution details:\n - Alternate Domain Names (CNAMEs): `cdn.your-domain.com`\n - Default Root Object: `index.html`\n - Logging: `Off`\n - Comments: `Created with express-cdn by @niftylettuce.`\n - Distribution State: `Enabled`\n5. Copy the generated Domain Name (e.g. `xyz.cloudfront.net`) to your clipboard.\n6. Log in to your-domain.com's DNS manager, add a new CNAME \"hostname\" of `cdn`, and paste the contents of your clipboard as the the \"alias\" or \"points to\" value.\n7. After the DNS change propagates, you can test your new CDN by visiting <http://cdn.your-domain.com> (the `index.html` file should get displayed).\n\n\n## Quick Start\n\n```bash\nnpm install express-cdn\n```\n\n```js\n// # express-cdn\n\nvar express = require('express')\n , path = require('path')\n , app = express.createServer()\n , semver = require('semver');\n\nvar sslEnabled = false\n\n// Set the CDN options\nvar options = {\n publicDir : path.join(__dirname, 'public')\n , viewsDir : path.join(__dirname, 'views')\n , domain : 'cdn.your-domain.com'\n , bucket : 'bucket-name'\n , endpoint : 'bucket-name.s3.amazonaws.com' // optional\n , key : 'amazon-s3-key'\n , secret : 'amazon-s3-secret'\n , hostname : 'localhost'\n , port : (sslEnabled ? 443 : 1337)\n , ssl : sslEnabled\n , production : true\n};\n\n// Initialize the CDN magic\nvar CDN = require('express-cdn')(app, options);\n\napp.configure(function() {\n app.set('view engine', 'jade');\n app.set('view options', { layout: false, pretty: true });\n app.enable('view cache');\n app.use(express.bodyParser());\n app.use(express.static(path.join(__dirname, 'public')));\n});\n\n// Add the view helper\nif (semver.lt(express.version, '3.0.0')) {\n app.locals({ CDN: CDN() });\n} else {\n app.dynamicHelpers({ CDN: CDN });\n}\n\napp.get('/', function(req, res, next) {\n res.render('basic');\n return;\n});\n\nconsole.log(\"Server started: http://localhost:1337\");\napp.listen(1337);\n```\n\n### Views\n\n#### Jade\n\n```jade\n// #1 - Load an image\n!= CDN('/img/sprite.png')\n\n// #2 - Load an image with a custom tag attribute\n!= CDN('/img/sprite.png', { alt: 'Sprite' })\n\n// #3 - Load a script\n!= CDN('/js/script.js')\n\n// #4 - Load a script with a custom tag attribute\n!= CDN('/js/script.js', { 'data-message': 'Hello' })\n\n// #5 - Load and concat two scripts\n!= CDN([ '/js/plugins.js', '/js/script.js' ])\n\n// #6 - Load and concat two scripts with custom tag attributes\n!= CDN([ '/js/plugins.js', '/js/script.js' ], { 'data-message': 'Hello' })\n\n// #7 - Load a stylesheet\n!= CDN('/css/style.css')\n\n// #8 - Load and concat two stylesheets\n!= CDN([ '/css/style.css', '/css/extra.css' ])\n```\n\n#### EJS\n\n```ejs\n<!-- #1 - Load an image -->\n<%- CDN('/img/sprite.png') %>\n\n<!-- #2 - Load an image with a custom tag attribute -->\n<%- CDN('/img/sprite.png', { alt: 'Sprite' }) %>\n\n<!-- #3 - Load a script -->\n<%- CDN('/js/script.js') %>\n\n<!-- #4 - Load a script with a custom tag attribute -->\n<%- CDN('/js/script.js', { 'data-message': 'Hello' }) %>\n\n<!-- #5 - Load and concat two scripts -->\n<%- CDN([ '/js/plugins.js', '/js/script.js' ]) %>\n\n<!-- #6 - Load and concat two scripts with custom tag attributes -->\n<%- CDN([ '/js/plugins.js', '/js/script.js' ], { 'data-message': 'Hello' }) %>\n\n<!-- #7 - Load a stylesheet -->\n<%- CDN('/css/style.css') %>\n\n<!-- #8 - Load and concat two stylesheets -->\n<%- CDN([ '/css/style.css', '/css/extra.css' ]) %>\n```\n\n### Automatically Rendered HTML\n\n#### Development Mode\n\n```html\n<!-- #1 - Load an image -->\n<img src=\"/img/sprite.png?v=1341214029\" />\n\n<!-- #2 - Load an image with a custom tag attribute -->\n<img src=\"/img/sprite.png?v=1341214029\" alt=\"Sprite\" />\n\n<!-- #3 - Load a script -->\n<script src=\"/js/script.js?v=1341214029\" type=\"text/javascript\"></script>\n\n<!-- #4 - Load a script with a custom tag attribute -->\n<script src=\"/js/script.js?v=1341214029\" type=\"text/javascript\" data-message=\"Hello\"></script>\n\n<!-- #5 - Load and concat two scripts -->\n<script src=\"/js/plugins.js?v=1341214029\" type=\"text/javascript\"></script>\n<script src=\"/js/script.js?v=1341214029\" type=\"text/javascript\"></script>\n\n<!-- #6 - Load and concat two scripts with custom tag attributes -->\n<script src=\"/js/plugins.js?v=1341214029\" type=\"text/javascript\" data-message=\"Hello\"></script>\n<script src=\"/js/script.js?v=1341214029\" type=\"text/javascript\" data-message=\"Hello\"></script>\n\n<!-- #7 - Load a stylesheet -->\n<link href=\"/css/style.css?v=1341214029\" rel=\"stylesheet\" type=\"text/css\" />\n\n<!-- #8 - Load and concat two stylesheets -->\n<link href=\"/css/style.css?v=1341214029\" rel=\"stylesheet\" type=\"text/css\" />\n<link href=\"/css/extra.css?v=1341214029\" rel=\"stylesheet\" type=\"text/css\" />\n```\n\n#### Production Mode\n\nThe protocol will automatically change to \"https\" or \"http\" depending on the SSL option.\n\nThe module will automatically upload and detect new/modified assets based off timestamp,\nas it utilizes the timestamp for version control! There is built-in magic to detect if\nindividual assets were changed when concatenating multiple assets together (it adds the\ntimestamps together and checks if the combined asset timestamp on S3 exists!).\n\n```html\n<!-- #1 - Load an image -->\n<img src=\"https://cdn.your-site.com/img/sprite.1341382571.png\" />\n\n<!-- #2 - Load an image with a custom tag attribute -->\n<img src=\"https://cdn.your-site.com/img/sprite.1341382571.png\" alt=\"Sprite\" />\n\n<!-- #3 - Load a script -->\n<script src=\"https://cdn.your-site.com/js/script.1341382571.js\" type=\"text/javascript\"></script>\n\n<!-- #4 - Load a script with a custom tag attribute -->\n<script src=\"https://cdn.your-site.com/js/script.1341382571.js\" type=\"text/javascript\" data-message=\"Hello\"></script>\n\n<!-- #5 - Load and concat two scripts -->\n<script src=\"https://cdn.your-site.com/plugins%2Bscript.1341382571.js\" type=\"text/javascript\"></script>\n\n<!-- #6 - Load and concat two scripts with custom tag attributes -->\n<script src=\"https://cdn.your-site.com/plugins%2Bscript.1341382571.js\" type=\"text/javascript\" data-message=\"Hello\"></script>\n\n<!-- #7 - Load a stylesheet -->\n<link href=\"https://cdn.your-site.com/css/style.1341382571.css\" rel=\"stylesheet\" type=\"text/css\" />\n\n<!-- #8 - Load and concat two stylesheets -->\n<link href=\"https://cdn.your-site.com/style%2Bextra.1341382571.css\" rel=\"stylesheet\" type=\"text/css\" />\n```\n\n\n## Custom Logging\n\nBy default log messages will be sent to the console. If you would like to use a custom logger function you may pass it in as `options.logger`\n\nThe example below uses the [Winston][12] logging library.\n\n```javascript\nvar winston = require('winston');\nwinston.add(winston.transports.File, {filename: 'somefile.log'});\n\n// Set the CDN options\nvar options = {\n publicDir : path.join(__dirname, 'public')\n , viewsDir : path.join(__dirname, 'views')\n , domain : 'cdn.your-domain.com'\n , bucket : 'bucket-name'\n , key : 'amazon-s3-key'\n , secret : 'amazon-s3-secret'\n , hostname : 'localhost'\n , port : 1337\n , ssl : false\n , production : true\n , logger : winston.info\n};\n\n// Initialize the CDN magic\nvar CDN = require('express-cdn')(app, options);\n\napp.configure(function() {\n app.set('view engine', 'jade');\n app.set('view options', { layout: false, pretty: true });\n app.enable('view cache');\n app.use(express.bodyParser());\n app.use(express.static(path.join(__dirname, 'public')));\n});\n\n// Add the dynamic view helper\napp.dynamicHelpers({ CDN: CDN });\n\n```\n\nAny output from express-cdn is now passed to `winston.info()` which writes to both `console` and `somefile.log`.\n\n\n## Lazyweb Requests\n\nThese are feature requests that we would appreciate contributors for:\n\n* Git SHA cachebusting instead of timestamp\n* Add support for multiple view directories\n* Add cache busting for CSS scraper\n* Add font CSS scraper for uploading fonts with proper mimetypes and cachebusting\n* Add options to pick CDN network (e.g. MaxCDN vs. Amazon vs. Rackspace)\n* Add tests for all asset types.\n* Modularization of `/lib/main.js` please!\n* Support Express 3.x.x+ and utilize async with view helper.\n* Convert from `fs.statSync` to `fs.stat` with callback for image assets modified timestamp hack.\n* Investigate why Chrome Tools Audit returns leverage proxy cookieless jargon.\n\n\n## Changelog\n\n* 0.1.0 - Fixed endpoint issue, fixed knox issue, added optipng binary, added jpegtran binary, **no longer requires optipng or jpegtran server dependencies!**\n\n* 0.0.9 - Allowed explicit setting of S3 endpoint (by @eladb)\n\n* 0.0.8 - Enabled string-only output for CDN assets.\n\n ```jade\n - var href = CDN('/img/full/foo.jpg', { raw : true });\n a(class=\"fancybox\", href=\"#{href}\")\n != CDN('/img/small/foo.jpg', { alt : 'Foo', width : 800, height : 600 })\n ```\n\n* 0.0.7 - Removed CSS minification due to over-optimization of the `clean-css` module.\n\n* 0.0.6 - Added temporary support for CSS usage of `background-image`, `background`, and `contents` attributes by absolute image paths.\n\n ```css\n /* Valid - Proper way to write CSS with express-cdn */\n #example-valid {\n background: url(/something.png);\n }\n\n /* Invalid - Don't do this! */\n #example-invalid {\n background: url(../something.png);\n }\n ```\n\n\n## Contributors\n\n* Nick Baugh <niftylettuce@gmail.com>\n* James Wyse <james@jameswyse.net>\n* Jon Keating <jon@licq.org>\n* Andrew de Andrade <andrew@deandrade.com.br>\n* [Joshua Gross](http://www.joshisgross.com) <josh@spandex.io>\n* Dominik Lessel <info@rocketeleven.com>\n* Elad Ben-Israel <elad.benisrael@gmail.com>\n\n\n## License\n\nThe MIT License\n\nCopyright (c) 2012- Nick Baugh niftylettuce@gmail.com (http://niftylettuce.com/)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n\n[1]: http://optipng.sourceforge.net/\n[2]: http://jpegclub.org/jpegtran/\n[3]: http://sass-lang.com/\n[4]: http://lesscss.org/\n[5]: http://learnboost.github.com/stylus/\n[6]: https://github.com/mishoo/UglifyJS/\n[7]: https://github.com/niftylettuce/express-cachebuster/\n[8]: http://h5bp.com/\n[9]: http://nodejs.org/api/zlib.html\n[10]: https://github.com/LearnBoost/knox/\n[11]: https://github.com/mxcl/homebrew/\n[12]: https://github.com/flatiron/winston/\n[13]: https://github.com/niftylettuce/express-cdn-cloudfront\n[14]: https://github.com/niftylettuce/express-cdn-maxcdn\n[15]: https://github.com/niftylettuce/express-cdn-cloudfiles\n[16]: https://github.com/niftylettuce/express-cdn-cloudflare\n",
"readmeFilename": "Readme.md",
"_id": "express-cdn@0.1.0",
"dist": {
"shasum": "6acb83cbbe02255888c2b35bba11adc39a7186a8"
},
"_resolved": "git://github.com/danielsantiago/express-cdn#d60b185504760d9bdd6fc93f2e1278222398a60d",
"_from": "git://github.com/danielsantiago/express-cdn",
"_fromGithub": true
}