-
Notifications
You must be signed in to change notification settings - Fork 13
/
server.js
52 lines (40 loc) · 1.68 KB
/
server.js
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
require('require-self-ref');
require('marko/express');
require('marko/node-require');
require('lasso/node-require-no-op').enable('.less', '.css');
var express = require('express');
var compression = require('compression'); // Provides gzip compression for the HTTP response
var serveStatic = require('serve-static');
var isProduction = process.env.NODE_ENV === 'production';
// Configure the RaptorJS Optimizer to control how JS/CSS/etc. is
// delivered to the browser
require('lasso').configure({
plugins: [
'lasso-less', // Allow Less files to be rendered to CSS
'lasso-marko' // Allow Marko templates to be compiled and transported to the browser
],
outputDir: __dirname + '/static', // Place all generated JS/CSS/etc. files into the "static" dir
bundlingEnabled: isProduction, // Only enable bundling in production
minify: isProduction, // Only minify JS and CSS code in production
fingerprintsEnabled: isProduction, // Only add fingerprints to URLs in production
});
var app = express();
var port = process.env.PORT || 8080;
// Enable gzip compression for all HTTP responses
app.use(compression());
// Allow all of the generated files under "static" to be served up by Express
app.use('/static', serveStatic(__dirname + '/static'));
require('./src/services/routes')(app);
// Map the "/" route to the home page
app.get('/', require('./src/pages/home'));
app.listen(port, function(err) {
if (err) {
throw err;
}
console.log('Listening on port %d', port);
// The browser-refresh module uses this event to know that the
// process is ready to serve traffic after the restart
if (process.send) {
process.send('online');
}
});