我正在尝试在我的 express 项目中为咖啡脚本和手写笔设置中间件编译。我的配置如下:
coffeescript = require 'connect-coffee-script'
stylus = require 'stylus'
# coffeescript
app.use coffeescript
src: __dirname + '/../assets/src/coffee'
dest: __dirname + '/../assets/public/js'
bare: true
# stylus with nib
app.use stylus.middleware
src: __dirname + '/../assets/src/stylus'
dest: __dirname + '/../assets/public/css'
compile: (str, path) ->
return stylus(str)
.set('filename', path)
.use(nib());
# public directory
app.use express.static __dirname + '/../assets/public'
我的(预期的)资产文件夹如下所示:
assets
-- public
---- js
---- css
-- src
---- coffee
---- stylus
localhost:3000/js/main.js <-- 404 localhost:3000/main.js <-- 404,但是会导致编译
localhost:3000/css/main.css <-- 404 localhost:3000/main.css <-- 404,但是会导致编译
我在这里误解了什么吗?谢谢!