mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-11 00:15:07 +00:00
build for production using r.js + jade is dev dependency now
This commit is contained in:
parent
a8e9516546
commit
fd76bab84d
1
.gitignore
vendored
1
.gitignore
vendored
@ -9,3 +9,4 @@ static/js/libs
|
||||
static/js/templates
|
||||
data/projects/**/workspace
|
||||
data/builds
|
||||
static/index.html
|
23
app.js
23
app.js
@ -1,9 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
var db = require('./db'),
|
||||
var env = process.env.NODE_ENV || 'development',
|
||||
db = require('./db'),
|
||||
http = require('http'),
|
||||
nodeStatic = require('node-static'),
|
||||
jade = require('jade'),
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
Steppy = require('twostep').Steppy,
|
||||
@ -24,15 +24,20 @@ var server = http.createServer(function(req, res) {
|
||||
return httpApi(req, res);
|
||||
}
|
||||
|
||||
// serve index for all app pages
|
||||
if (req.url.indexOf('/data.io.js') === -1) {
|
||||
if (!req.url.match(/(js|css|fonts)/)) {
|
||||
// Compile a function
|
||||
var index = jade.compileFile(__dirname + '/views/index.jade');
|
||||
res.write(index());
|
||||
res.end();
|
||||
} else {
|
||||
if (/(js|css|fonts)/.test(req.url)) {
|
||||
staticServer.serve(req, res);
|
||||
} else {
|
||||
// serve index for all app pages
|
||||
if (env === 'development') {
|
||||
var jade = require('jade');
|
||||
// Compile a function
|
||||
var index = jade.compileFile(__dirname + '/views/index.jade');
|
||||
res.write(index({env: env}));
|
||||
res.end();
|
||||
} else {
|
||||
staticServer.serve(req, res);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -9,7 +9,10 @@
|
||||
"makeTestRepos": "rm -rf test/repos/{mercurial,git}; cd test/repos/ && tar -xf mercurial.tar.gz && tar -xf git.tar.gz",
|
||||
"test": "npm run makeTestRepos && mocha --bail --reporter=spec test/index --timeout 4000",
|
||||
"dev": "gulp",
|
||||
"sync": "npm install && npm prune && bower install && bower prune"
|
||||
"sync": "npm install && npm prune && bower install && bower prune",
|
||||
"buildJs": "r.js -o static/js/requirejs/buid.js",
|
||||
"buildHtml": "jade views/index.jade --obj '{\"env\": \"production\"}' -o static/",
|
||||
"build": "npm run buildJs && npm run buildHtml"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -42,7 +45,6 @@
|
||||
"colors": "1.1.2",
|
||||
"cron": "1.0.9",
|
||||
"data.io": "0.3.0",
|
||||
"jade": "1.9.2",
|
||||
"nlevel": "1.0.2",
|
||||
"node-static": "0.7.6",
|
||||
"socket.io": "1.3.5",
|
||||
@ -56,12 +58,14 @@
|
||||
"gulp-less": "3.0.3",
|
||||
"gulp-nodemon": "2.0.3",
|
||||
"gulp-react-jade-amd": "git://github.com/vladimir-polyakov/gulp-react-jade-amd",
|
||||
"jade": "1.11.0",
|
||||
"main-bower-files": "2.7.0",
|
||||
"medeadown": "1.1.7",
|
||||
"memdown": "1.0.0",
|
||||
"mocha": "1.18.2",
|
||||
"nci-yaml-reader": "0.1.0",
|
||||
"nodemon": "1.3.7",
|
||||
"requirejs": "2.1.19",
|
||||
"sinon": "1.14.1"
|
||||
}
|
||||
}
|
||||
|
14
static/js/requirejs/buid.js
Normal file
14
static/js/requirejs/buid.js
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
({
|
||||
mainConfigFile: 'development.js',
|
||||
baseUrl: '../',
|
||||
paths: {
|
||||
socketio: 'empty:',
|
||||
_dataio: 'empty:'
|
||||
},
|
||||
name: 'app/app',
|
||||
preserveLicenseComments: false,
|
||||
optimize: 'uglify2',
|
||||
useStrict: true,
|
||||
out: '../../scripts/app.js'
|
||||
});
|
@ -1,14 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
require.config({
|
||||
baseUrl: '/js/',
|
||||
baseUrl: '/js',
|
||||
paths: {
|
||||
socketio: '/socket.io/socket.io',
|
||||
_dataio: '/data.io',
|
||||
underscore: 'libs/underscore/underscore',
|
||||
react: 'libs/react/react-with-addons',
|
||||
'react-router': 'libs/react-router/build/umd/ReactRouter',
|
||||
reflux: 'libs/reflux/dist/reflux',
|
||||
_dataio: '/data.io',
|
||||
socketio: '/socket.io/socket.io.js',
|
||||
jquery: 'libs/jquery/jquery',
|
||||
ansi_up: 'libs/ansi_up/ansi_up',
|
||||
'bootstrap/collapse': 'libs/bootstrap/js/collapse',
|
8
static/js/requirejs/production.js
Normal file
8
static/js/requirejs/production.js
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
require.config({
|
||||
baseUrl: '/scripts',
|
||||
paths: {
|
||||
socketio: '/socket.io/socket.io',
|
||||
_dataio: '/data.io',
|
||||
}
|
||||
});
|
0
static/scripts/app.js
Normal file
0
static/scripts/app.js
Normal file
@ -5,7 +5,18 @@ html
|
||||
|
||||
link(href="/css/index.css", rel="stylesheet", type="text/css")
|
||||
|
||||
script(data-main="/js/main" src="/js/libs/requirejs/require.js")
|
||||
script
|
||||
include ../static/js/libs/requirejs/require.js
|
||||
|
||||
if env === 'development'
|
||||
script
|
||||
include ../static/js/requirejs/development.js
|
||||
else
|
||||
script
|
||||
include ../static/js/requirejs/production.js
|
||||
script
|
||||
include ../static/scripts/app.js
|
||||
|
||||
script(type="text/javascript").
|
||||
require(['app/app']);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user