I've set up a node express app and incorporated sass support for the CSS. However, when I attempt to access
http://myhost.com:port/css/whatever.css
, the whatever.css
file is generated in the express_app_root/public/css directory as expected. The *.scss source files are located in the express_app_root/sass directory.
The issue arises when the browser fails to load the CSS file on the first request but successfully loads it on the second request. How can I ensure that the CSS file generates and loads on the initial GET request?
Below is the snippet of code used to load and configure node-sass:
var sass = require("node-sass");
...
app.use(sass.middleware({
src: path.join(__dirname, 'sass'),
dest: path.join(__dirname, 'public/css'),
prefix: '/css',
debug: true
}),express.static('/css',path.join(__dirname, '/public')) );