【发布时间】:2014-02-09 02:25:47
【问题描述】:
我在使用node-sass library 将样式表呈现到我的节点应用程序中的页面时遇到问题。服务器返回200,我可以使用开发工具检查main.scss,但是内容页面实际上并没有被修改。
我已经确保express.static 指令出现在 sass.middleware 之后,并在我的一条路径中添加了sass.render(现已删除)以尝试记录错误。它没有返回错误。此外,index.html 包含 <link rel="stylesheet" href="stylesheets/main.scss">。非常感谢任何帮助!
目录:
├── app.js
├── launch.sh
├── package.json
├── public
│ ├── index.html
│ └── stylesheets
│ └── main.scss
└── spec
├── unit.js
└── unitExamples.js
app.js:
var express = require('express'),
sass = require('node-sass'),
path = require('path'),
app = express();
app.configure(function(){
app.use(express.logger('dev'));
app.use(express.urlencoded());
app.use(express.json());
app.use(
sass.middleware({
src: __dirname + '/public/stylesheets',
dest: __dirname + '/public/',
debug: true,
outputStyle: 'compressed'
})
);
app.use(express.static(path.join(__dirname, 'public')));
});
app.get('/', function(req,res){
res.sendfile(path.join(__dirname, '/public/index.html'));
});
var port = process.env.PORT || 8080;
app.listen(port);
console.log("App listening on port " + port);
【问题讨论】: