我在节点应用程序中使用了sass,因为我已经安装了这个依赖项&n 34; npm install node-sass-middleware"。它没有生成style.css文件意味着不编译style.scss文件。而我正在使用快递。请帮忙
我的app.js中的代码
app.use(sassMiddleware({
src: path.join(__dirname, 'public/scss'),
dest: path.join(__dirname, 'public/css'),
debug: true,
indentedSyntax: true,
outputStyle: 'compressed'
}));
// Static folder
app.use(express.static(path.join(__dirname, 'public')));
提前致谢
app.js
var express = require('express');
var sass = require('node-sass');
var sassMiddleware = require('node-sass-middleware');
var path = require('path');
const app = express();
app.set('view engine', 'ejs');
app.use(sassMiddleware({
src: path.join(__dirname, 'public/scss'),
dest: path.join(__dirname, 'public/css'),
debug: true,
indentedSyntax: false,
outputStyle: 'compressed',
prefix: '/css'
}));
// Static folder
app.use(express.static(path.join(__dirname, 'public')));
app.get('/', (req,res)=>{
res.render('index');
});
app.get('/download', function (req, res, next) {
var filePath = "public/files/Bijitashya (2).doc"; // Or format the path using the `id` rest param
var fileName = "Bijitashya (2).doc"; // The default name the browser will use
res.download(filePath, fileName);
});
const port = process.env.PORT || 5000;
app.listen(port, () =>{
console.log(`Server started on port ${port}`);
});
的package.json
{
"name": "portfolio",
"version": "1.0.0",
"description": "My Portfolio",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "Bijitashya",
"license": "ISC",
"dependencies": {
"bootstrap": "4.0.0",
"ejs": "^2.5.7",
"express": "^4.16.3",
"font-awesome": "^4.7.0",
"jquery": "^3.3.1",
"node-sass": "^4.9.0",
"node-sass-middleware": "^0.11.0",
"popper.js": "^1.12.9"
}
}
答案 0 :(得分:0)
假设您的目录名称中包含需要编译的.scss
个文件。使用选项indentedSyntax: true
,中间件将尝试查找.sass
个文件而不是.scss
个文件。因此,如果您没有任何.sass
个文件,它将不是任何输出或编译文件
您只需将选项设置为false
或只删除该选项,因为false
是其默认值。