Comments (3)
We do not cache the stylesheet results at all, but instead rely on 'modified timestamp' of .css
vs. .scss
/.sass
.
We definitely compile if either of following conditions are met:
- options.force is set
- the target CSS does not exist
- the target CSS exists, and
sass_source_modified_time
>css_target_modified_time
, then recompile
Otherwise (after asserting all the implementation details), we skip the compilation step and simply invoke the caller's next middleware -- which in most cases is either (postcss-based) minifier or static files middleware.
from node-sass-middleware.
Mh... and the sass timestamp is copied right over from the original css file ?
Otherwise I would assume the sass timestamp could always differ because of the time it takes for the file to be converted.
Also, I noticed that the middleware seems to check any html files for external files ( in debug mode .js and .jpg files also pop up ), and then look into those folders, which I find somewhat peculiar.
For example, given the following folder structure
/stylesheets
--- /sass
--- /compiled_css/
----/third_party_library_css
Yet, when set to
sassMiddleware({
/* Options */
root: __dirname + "/public/stylesheets",
src: "/sass",
dest: "/css_compiled",
I still see in the debug that the sassMiddleware is looking for files like "selectbox.js.min" to convert, even though those are, besides scripts, not even in the src folder.
Shouldn't the library be only looking in the source folder, instead of into all the paths defined in all html files?
Also, is there a way to skip all files but sass files ?
from node-sass-middleware.
sass timestamp is copied right over from the original css file ?
The modified timestamp is set by OS when user or application modifies some file, we read the file metadata via node.js standard file-system API (mtime
in fstat
object: https://nodejs.org/api/fs.html#fs_class_fs_stats).
the debug that the sassMiddleware is looking for files like "selectbox.js.min" to convert
Nope, in debug, we just log a message that our middleware has 'seen' this request, but skip to the next()
one right away, if the requested asset is a non-css file.
Also, is there a way to skip all files but sass files?
The concept of middleware is that the server (express.js
et al.) passes through the request to the middleware chain; the first middleware calls the second one, second calls the third and so on. If some middleware wants to handle the request, it will do so and either:
- pass the control to the next one by calling
next()
function injected by the server app - respond success (200) or error (404 etc.) and terminate the middleware pipe.
The middleware is configured by the consumer and next()
follows the order the user has specified:
e.g.
var server = require('express')();
var sassMiddleware = require('node-sass-middleware');
var postcssMiddleware = require('postcss-middleware');
server
.use ( sassMiddleware ( sassMiddlewareOptions ) ) // this middleware will be called first
.use ( postcssMiddleware ( postcssMiddlewareOptions ) ) // this will be called when previous
// one invokes next()
/* and so on */
;
from node-sass-middleware.
Related Issues (20)
- Security vulnerability HOT 1
- Sass is compiling in public directory and Sass directory HOT 1
- Publish release 0.12.0 to npm HOT 4
- Confusing documentation HOT 3
- Incorrect path concatenation HOT 3
- Extend the src field so that it can take multiple directory locations HOT 7
- Pre-existing files in the destination assumes there is a source file for it HOT 1
- invalid code loads infinitely
- support for dart sass version without native dependencies HOT 6
- The code is half-complete, the project is dead HOT 4
- Vulnerability node-sass-middleware > node-sass > meow > trim-newlines
- High Vulnerability in node-sass-middleware > node-sass > node-gyp > tar
- Node v16 compatibility HOT 2
- ChainAlert: npm package release (1.0.0) has no matching tag in this repo HOT 1
- npm install issues (fix)
- Can't install node-sass-middleware with latest node LTS (16.16.0) HOT 2
- Regular expression denial of service in scss-tokenizer HOT 1
- [sass] error: Incompatible units: 'vh' and 'rem'. HOT 1
- node-sass-middleware installation error HOT 1
- Dependency on a vulnerable version of node-sass /request
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-sass-middleware.