mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
Added gzip support #82
This commit is contained in:
parent
3b43119d93
commit
c52fc549e1
6 changed files with 20 additions and 9 deletions
|
|
@ -1,10 +1,11 @@
|
||||||
define([
|
define([
|
||||||
'http',
|
'http',
|
||||||
'node-static',
|
'node-static',
|
||||||
'Server/Api'
|
'Server/Api',
|
||||||
|
'zlib'
|
||||||
],
|
],
|
||||||
|
|
||||||
function (http, nodeStatic, Api) {
|
function (http, nodeStatic, Api, zlib) {
|
||||||
|
|
||||||
function HttpServer (options, coordinator) {
|
function HttpServer (options, coordinator) {
|
||||||
options.port = options.port || 1234;
|
options.port = options.port || 1234;
|
||||||
|
|
@ -20,7 +21,8 @@ function (http, nodeStatic, Api) {
|
||||||
HttpServer.prototype.init = function (options) {
|
HttpServer.prototype.init = function (options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var fileServer = new nodeStatic.Server(options.rootDirectory, { cache: options.caching });
|
//gzip true serves gzip file if there is one with .gz next to the original && if browser supports it
|
||||||
|
var fileServer = new nodeStatic.Server(options.rootDirectory, { cache: options.caching, gzip: true });
|
||||||
|
|
||||||
this.server = http.createServer(
|
this.server = http.createServer(
|
||||||
function (req, res) {
|
function (req, res) {
|
||||||
|
|
@ -48,7 +50,7 @@ function (http, nodeStatic, Api) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case req.url == '/client.min.js':
|
case req.url == '/client.min.js':
|
||||||
fileServer.serveFile('./client.min.js', 200, {}, req, res);
|
fileServer.serveFile('./build/client.min.js', 200, {}, req, res);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case req.url == '/require.js':
|
case req.url == '/require.js':
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
({
|
({
|
||||||
baseUrl: "app",
|
baseUrl: "../app",
|
||||||
paths: {
|
paths: {
|
||||||
"screenfull": "../node_modules/screenfull/dist/screenfull",
|
"screenfull": "../node_modules/screenfull/dist/screenfull",
|
||||||
"socketio": "../node_modules/socket.io/node_modules/socket.io-client/dist/socket.io"
|
"socketio": "../node_modules/socket.io/node_modules/socket.io-client/dist/socket.io"
|
||||||
9
build/build.sh
Executable file
9
build/build.sh
Executable file
|
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/bash
|
||||||
|
if [ -d "build" ]; then
|
||||||
|
cd build
|
||||||
|
echo "\\033[1;36mcompiling client scripts...\\033[0m"
|
||||||
|
rm -f "client.min.js.gz"
|
||||||
|
../node_modules/requirejs/bin/r.js -o build.js > /dev/null \
|
||||||
|
&& gzip --keep client.min.js && echo "\\033[1;32mdone.\\033[0m"
|
||||||
|
cd ..
|
||||||
|
fi
|
||||||
2
client.min.js → build/client.min.js
vendored
2
client.min.js → build/client.min.js
vendored
File diff suppressed because one or more lines are too long
BIN
build/client.min.js.gz
Normal file
BIN
build/client.min.js.gz
Normal file
Binary file not shown.
|
|
@ -27,6 +27,6 @@
|
||||||
"config": { "port": "1234" },
|
"config": { "port": "1234" },
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prestart": "node_modules/requirejs/bin/r.js -o build.js optimize=none > /dev/null && echo '\\033[1;32mcompiled.\\033[0m'"
|
"prestart": "./build/build.sh"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue