如何设置 SASS 忽略静态目录中的某些文件夹(Express) [英] How can I set SASS to ignore certain folders in static directory (Express)

查看:45
本文介绍了如何设置 SASS 忽略静态目录中的某些文件夹(Express)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何让 node-sass-middleware 忽略静态文件夹中的其他所有内容,除了 scss 目录中的内容?

How can I make node-sass-middleware ignore everything else in the static folder, except for what is in the scss directory?

我是 Express/Node 和 SASS 的新手.我想定义我的静态文件夹来拥有自动编译的 SCSS 文件,但也有 CSS 文件只是坐在那里并且不被 node-sass-middleware

I'm new to Express/Node and SASS. I want to define my static folder to have SCSS files that are auto-compiled, but also have CSS files that just sit there and aren't touched by node-sass-middleware

问题是,node-sass-middleware 期望我的静态文件夹中的每个 CSS 文件都应该有一个对应的 SCSS 文件.

The problem is, node-sass-middleware is expecting that every CSS file in my static folder should have a corresponding SCSS file.

var express = require('express');
var sass = require('node-sass-middleware');
var app = express();
app.use(
    sass({
        src: __dirname + '/assets/scss',
        dest: __dirname + '/assets',
        debug: true,
    })
);
app.use(express.static('assets'));

文件夹结构

-assets
--css
--scss
--static
---css

推荐答案

不确定将 .css 文件放在 scss 文件夹中有多大意义.您不能将 .css 文件保存在您的 assets/static/css 文件夹中吗?然后您也可以将 dest 更改为 assets/static/css.

Not sure how much sense it makes to put .css files in your scss folder. Can't you just keep the .css files in your assets/static/css folder? And then you can change your dest to assets/static/css as well.

然后你想把你的 express.static 改成 app.use(express.static('assets/static'));

And then you would want to change you're express.static to app.use(express.static('assets/static'));

这篇关于如何设置 SASS 忽略静态目录中的某些文件夹(Express)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆