-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatic.js
More file actions
52 lines (42 loc) · 1.34 KB
/
static.js
File metadata and controls
52 lines (42 loc) · 1.34 KB
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
/**
* Returns an Express Router with bindings for the Admin UI static resources,
* i.e files, less and browserified scripts.
*
* Should be included before other middleware (e.g. session management,
* logging, etc) for reduced overhead.
*/
var browserify = require('./browserify');
var express = require('express');
var less = require('less-middleware');
var path = require('path');
var router = express.Router();
/* Prepare browserify bundles */
var bundles = {
fields: browserify('fields.js', 'FieldTypes'),
home: browserify('views/home.js'),
item: browserify('views/item.js'),
list: browserify('views/list.js')
};
router.prebuild = function() {
bundles.fields.build();
bundles.home.build();
bundles.item.build();
bundles.list.build();
};
/* Prepare LESS options */
var reactSelectPath = path.join(path.dirname(require.resolve('react-select')), '..');
var lessOptions = {
render: {
modifyVars: {
reactSelectPath: JSON.stringify(reactSelectPath)
}
}
};
/* Configure router */
router.use('/styles', less(path.join(__dirname, '../public/styles'), lessOptions));
router.use(express.static(path.join(__dirname, '../public')));
router.get('/js/fields.js', bundles.fields.serve);
router.get('/js/home.js', bundles.home.serve);
router.get('/js/item.js', bundles.item.serve);
router.get('/js/list.js', bundles.list.serve);
module.exports = router;