question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSS isn't compiled after the first success?

See original GitHub issue

I’m running into a weird issue using this middleware with Express. Here is our usage:

var sass = require('node-sass-middleware');
app.use('/css', sass({
  src: __dirname + '/style/sass',
  dest: __dirname + '/style/css',
  outputStyle: 'nested',
  debug: true,
  force: true,
  sourceMap: true
}));

Our issue is that if we don’t pass force: true, the CSS for our source file only compiles successfully the first time, and 404s after that. I’ve cloned the repo and added a test case that attempts to simulate this by simply requesting a stylesheet twice in a row, but I can’t reproduce it.

Here’s what happens on the console:

  1. The first request outputs the sass middleware’s debug messages, as expected:

    source: /Users/allens/work/eiti-data/style/sass/main.scss
    dest: /Users/allens/work/eiti-data/style/css/main.css
    read: /Users/allens/work/eiti-data/style/css/main.css
    render: /Users/allens/work/eiti-data/style/sass/main.scss
    render: /Users/allens/work/eiti-data/style/css/main.css.map
    source: /Users/allens/work/eiti-data/style/sass/main.scss
    dest: /Users/allens/work/eiti-data/style/css/main.css
    
  2. The second time around, nothing happens and Express returns a 404.

  3. The third time around, the middleware outputs just the source and dest paths, but no render calls:

    source: /Users/allens/work/eiti-data/style/sass/main.scss
    dest: /Users/allens/work/eiti-data/style/css/main.css
    

I can try to create a standalone test case for this if you’d like, but I just wanted to make sure that I’m not doing something glaringly wrong or missing something totally obvious. As you can see, there’s nothing very complex going on in our SCSS source. Thank you!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
torfsencommented, Dec 6, 2016

@am11 That seems indeed to fix the issue, thanks!

I copied my original code from the Express example in the README, so I’ve created a PR (#89) to fix that example.

1reaction
am11commented, Dec 5, 2016

@torfsen, does it work if you replace:

app.use(express.static(path.join(__dirname, 'public')))

with:

app.use('/public', express.static(path.join(__dirname, 'public')))

See a working example at: https://github.com/sass/node-sass-middleware/issues/70#issuecomment-261822665 and working project at https://github.com/sass/node-sass-middleware/issues/70#issuecomment-261835085.

Read more comments on GitHub >

github_iconTop Results From Across the Web

less compliler will not write to my css file, although it says ...
I'm using the {less} compiler (http://incident57.com/less/) with Coda 1.7.2 (first time trying this!) {less} gives me a success message, ...
Read more >
Why We're Breaking Up with CSS-in-JS - DEV Community ‍ ‍
Here are the drawbacks I saw when looking at Compiled in particular: Styles are still inserted when a component mounts for the first...
Read more >
What are CSS Modules and why do we need them?
CSS files in which all class names and animation names are scoped locally by default. So CSS Modules is not an official spec...
Read more >
How to Troubleshoot CSS Not Working - WPForms
Colon and semicolon: Be sure to include a colon (:) between every CSS property and value, and a semicolon (;) after every value...
Read more >
Laravel Mix Does Not Pull In CSS - Laracasts
I have everything working nicely on my development server, however when I implement the the ... My mix will compile, but does not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found