Decide whether to live-compile stylus based on the presence of style.styl

This commit is contained in:
Nadav Ivgi 2018-03-06 07:49:44 +02:00
parent 2bc30b3a5b
commit cfc28ee30e
2 changed files with 3 additions and 1 deletions

View File

@ -2,3 +2,4 @@ node_modules
.env
src
start.sh
static/style.styl

View File

@ -1,3 +1,4 @@
import fs from 'fs'
import path from 'path'
import { pwrap, pick, fcurrency, fmsat, pngPixel } from './lib/util'
@ -39,7 +40,7 @@ app.use(require('body-parser').urlencoded({ extended: false }))
app.use(require('csurf')({ cookie: true }))
// Static assets
if (app.settings.env == 'development' && require.resolve('stylus'))
if (fs.existsSync(path.join(conf.static_dir, 'style.styl')))
app.use('/_assets', require('stylus').middleware({ src: conf.static_dir, serve: true }))
app.use('/_assets', require('express').static(conf.static_dir))