Skip to content

Commit 11b3131

Browse files
committed
Merge branch 'master' of github.com:requirejs/example-jquery-shim
2 parents 59d7541 + d1ce129 commit 11b3131

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ define(["jquery", "jquery.alpha", "jquery.beta"], function($) {
6464

6565
###How to see it in action
6666

67-
Just serve up the www/ folder using any web server you'd like.
67+
Just serve up the www/ folder using any web server you'd like. To get you set up quickly, we've included a node.js static file server in tools/. Start the server by typing `node tools/server.js` from the command line, and then go to [localhost:8888/www/app.html](http://localhost:8888/www/app.html) in your browser.
6868

69-
###How to optimize ut using r.js
69+
###How to optimize it using r.js
7070
To use the optimizer, you need [node.js](http://nodejs.org) or Java 6 installed. These instructions assume Node is being used. See the [Optimization page](http://requirejs.org/docs/optimization.html) for more information.
7171

7272
r.js and a build configuration is included in the tools/ folder. To build, navigate to tools/ and type `node r.js -o build.js`. You will find the built product in the www-build folder. If you serve that directory instead, you can see in the network panel of the web developer tools that the files aren't loaded separately any more.

tools/server.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* node static file server:
3+
* modified from https://gist.github.com/rpflorence/701407
4+
*/
5+
/*jslint evil: true, nomen: true, sloppy: true */
6+
7+
var http = require('http'),
8+
url = require('url'),
9+
path = require('path'),
10+
fs = require('fs'),
11+
port = process.argv[2] || 8888,
12+
types = {
13+
'html': 'text/html',
14+
'js': 'application/javascript'
15+
};
16+
17+
http.createServer(function (request, response) {
18+
var uri = url.parse(request.url).pathname,
19+
filename = path.join(__dirname, '..', uri);
20+
21+
fs.exists(filename, function (exists) {
22+
if (!exists) {
23+
response.writeHead(404, {'Content-Type': 'text/plain'});
24+
response.write('404 Not Found\n');
25+
response.end();
26+
return;
27+
}
28+
29+
var type = filename.split('.');
30+
type = type[type.length - 1];
31+
32+
response.writeHead(200, { 'Content-Type': types[type] + '; charset=utf-8' });
33+
fs.createReadStream(filename).pipe(response);
34+
});
35+
}).listen(parseInt(port, 10));
36+
37+
console.log('Static file server running at\n => http://localhost:' + port + '/\nCTRL + C to shutdown');

0 commit comments

Comments
 (0)