sass / node-sass-middleware

connect middleware extracted from node-sass
MIT License
263 stars 84 forks source link

net::ERR_ABORTED #116

Closed smsbhatt closed 6 years ago

smsbhatt commented 6 years ago

expressJs:

The scss file will not get compiled every time, first request ll have the file and other don't.

once the middle-ware stops compiling i need to restart the server to have continues file compilation.

app.use(bodyParser.urlencoded({
    extended: true
}));
app.use(bodyParser.json());
app.use(methodOverride());

// view engine setup
app.set('views', path.join(__dirname, '../server/views'));
app.engine('html', Ejs.renderFile);
app.set('view engine', 'html');
app.use(sassMiddleware({
    /* Options */
    src: path.join(__dirname, '../../vueJs/styles/'),
    dest: path.join(__dirname, '../../public'),
    debug: true,
    outputStyle: 'compressed',
    prefix:  '/assets/css/',  // Where prefix is at <link rel="stylesheets" href="prefix/style.css"/>
    beepOnError: true
}));
// Serving static files
app.use(express.static(path.join(__dirname, '../../public')));

app.use(passport.initialize());
app.use(passport.session());
passportConfig(passport);
smsbhatt commented 6 years ago

uff at last i fould a solution

i hope if there is a compiled file already, the middleware doesn't do anything thinking there is a compiled file. issue was : --first request the middleware compiles the file and saves it . --second request it just ignores the request thinking file exist. But file is not rendered to the request (issue).

solution i found:

    app.use(sassMiddleware({
        /* Options */
        src: path.join(__dirname, '../../vueJs/styles/'),
        dest: path.join(__dirname, '../../public'),
        debug: true,
        outputStyle: 'compressed',
        prefix:  '/assets/css/', 
        response: true // doesnt saves the file it just pipe the file directly to the response.
    }));

pass a additional param "response: true"