forked from hotosm/oam-design-system
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulp-addons.js
25 lines (22 loc) · 902 Bytes
/
gulp-addons.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
var path = require('path');
// /////////////////////////////////////////////////////////////////////////////
// ----------------------- Node module settings ------------------------------//
// -------------------------- (Do not modify) --------------------------------//
module.exports.scssPath = path.join(__dirname, './assets/styles');
module.exports.graphicsPath = path.join(__dirname, './assets/graphics');
module.exports.graphicsMiddleware = function (fs) {
return function (req, res, next) {
var r = new RegExp('/?assets/graphics/(.+)');
var pieces = req.url.match(r);
if (!pieces) return next();
try {
if (pieces[1].match(/\.svgz?$/)) {
res.setHeader('Content-Type', 'image/svg+xml');
}
res.end(fs.readFileSync(path.join(__dirname, './assets/graphics', pieces[1])));
} catch (e) {
// Nothing to do there.
}
return next();
};
};