0

I'm using node-sass-middleware in my Express app. It's working for the main routes (home/sign-in/sign-up etc), but when I request a route like '/collections', which is locate in a different folder, it starts to looks for the scss file under a different path and it doesn't compile.

The problem is not that __dirname is changing, as you can see, the middleware is looking for '/collection' after the __dirname, which is the same in both cases.

app.js

app.use(sassMiddleware({
         src: (__dirname + '/sass'),
         dest: (__dirname + '/public'),
         debug: true,
         })
);

Directory

routes(folder)

...index.js

...collections.js

Terminal messages -

(/sign-in) /Users/Daniel/code/dansiberry/learnbox/sass/app.scss

(/collections/new) /Users/Daniel/code/dansiberry/learnbox/sass/collections/app.scss does not exist

dan101
  • 63
  • 1
  • 1
  • 6
  • Possible duplicate of [Determine project root from a running node.js application](https://stackoverflow.com/questions/10265798/determine-project-root-from-a-running-node-js-application) – Jamie Barker Jul 06 '17 at 13:09
  • Have you tried `path.join(__dirname, 'public')`? – Cisco Jul 06 '17 at 13:38
  • The problem is not the defined path, please look closely at the terminal errors. The middleware is attaching a '/collections' to the path regardless of what it is – dan101 Jul 06 '17 at 14:18

0 Answers0