mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
restructured scripts for building and some improvements
This commit is contained in:
parent
74134a53af
commit
8dbc088813
8 changed files with 231 additions and 15 deletions
|
|
@ -2,10 +2,10 @@ define([
|
|||
'http',
|
||||
'node-static',
|
||||
'Server/Api',
|
||||
'zlib'
|
||||
'fs'
|
||||
],
|
||||
|
||||
function (http, nodeStatic, Api, zlib) {
|
||||
function (http, nodeStatic, Api, fs) {
|
||||
|
||||
function HttpServer (options, coordinator) {
|
||||
options.port = options.port || 1234;
|
||||
|
|
@ -46,7 +46,13 @@ function (http, nodeStatic, Api, zlib) {
|
|||
break;
|
||||
|
||||
case req.url == '/client.js':
|
||||
fileServer.serveFile('./client.js', 200, {}, req, res);
|
||||
fs.exists('./build/client.min.js', function (exists) {
|
||||
if (process.env.NODE_ENV && process.env.NODE_ENV == 'production' && exists) {
|
||||
fileServer.serveFile('./build/client.min.js', 200, {}, req, res);
|
||||
} else {
|
||||
fileServer.serveFile('./client.js', 200, {}, req, res);
|
||||
}
|
||||
});
|
||||
break;
|
||||
|
||||
case req.url == '/client.min.js':
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
#!/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 -c client.min.js > client.min.js.gz && echo "\\033[1;32mdone.\\033[0m"
|
||||
cd ..
|
||||
fi
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
"socketio": "../node_modules/socket.io/node_modules/socket.io-client/dist/socket.io"
|
||||
},
|
||||
name: "../client",
|
||||
out: "client.min.js",
|
||||
out: "../build/client.min.js",
|
||||
onBuildRead: function (moduleName, path, contents) {
|
||||
var contents = contents.replace(/\" \+ GLOBALS.context \+ \"/g, "Client");
|
||||
return contents;
|
||||
206
config/client.min.js
vendored
Normal file
206
config/client.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -27,6 +27,6 @@
|
|||
"config": { "port": "1234" },
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"prestart": "./build/build.sh"
|
||||
"prestart": "scripts/build.sh"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
scripts/build.sh
Executable file
13
scripts/build.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
if env | grep -q "^NODE_ENV=production$"
|
||||
then
|
||||
echo "[ PRODUCTION ]"
|
||||
mkdir -p build
|
||||
echo "- compiling client scripts.."
|
||||
rm -f "build/client.min.js.gz"
|
||||
node_modules/requirejs/bin/r.js -o config/build-profile.js > /dev/null \
|
||||
&& gzip -c build/client.min.js > build/client.min.js.gz \
|
||||
&& echo "- done."
|
||||
else
|
||||
echo "[ DEVELOPMENT ]"
|
||||
fi
|
||||
|
|
@ -78,6 +78,6 @@
|
|||
<canvas id="canvas"></canvas>
|
||||
</div>
|
||||
</article>
|
||||
<script data-main="client.min" src="require.js"></script>
|
||||
<script data-main="client" src="require.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue