Why gulp doesn't throw an error if the import path is wrong in a sass file?
up vote
0
down vote
favorite
My question is, why I don't get any error message from the gulp tasks when I use wrong import path in my scss files?
I use this gulp tasks to compile and minify my sass files to their destination directory
// gulpfile.js
var gulp = require('gulp');
var sass = require('gulp-sass');
var frontendSassSrcDir = 'build/frontend/sass/**';
var frontendCssDestDir = 'public/css/';
var backendSassSrcDir = 'build/backend/sass/**';
var backendCssDestDir = 'public/css/';
gulp.task('frontend-style', function()
return gulp
.src(frontendSassSrcDir + '/*.scss')
.pipe(sass(outputStyle: 'compressed').on('error', sass.logError))
.pipe(gulp.dest(frontendCssDestDir))
);
gulp.task('backend-style', function()
return gulp.src(backendSassSrcDir + '/*.scss')
.pipe(sass(outputStyle: 'compressed').on('error', sass.logError))
.pipe(gulp.dest(backendCssDestDir));
);
gulp.task('default-watch', function()
gulp.watch('build/frontend/sass/**/*.scss', ['frontend-style']);
gulp.watch('build/backend/sass/**/*.scss', ['backend-style']);
);
here is the folder structure
- project-folder
- build
- backend
- sass
- backend.scss
- frontend
- sass
- frontend.scss
- node_modules
- public
- css
- backend.css
- frontend.css
gulpfile.js
Here is the wrong content of my scss file
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";
if I run this command in command line, it looks like it works, because I get this output, however it generates an empty css file
$ node_modules/gulp/bin/gulp.js frontend-style
[20:50:40] Using gulpfile /opt/workspace/www/bhajanBook/gulpfile.js
[20:50:40] Starting 'frontend-style'...
[20:50:40] Finished 'frontend-style' after 73 ms
why it doesn't give me the same error message like this command?
$ node_modules/sass/sass.js ./build/frontend/sass/frontend.scss ./public/css/frontend.css
Error: Can't find stylesheet to import.
@import "node_modules/bootstrap/scss/functions";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
build/frontend/sass/frontend.scss 1:9 root stylesheet
Running it in command line helped me to fix it
@import "./../../../node_modules/bootstrap/scss/functions";
@import "./../../../node_modules/bootstrap/scss/variables";
@import "./../../../node_modules/bootstrap/scss/mixins";
I learned that on('error', sass.logError) throws an error if I make a mistake in the gulpfile.js but it shouldn't be responsible for catching this error too?
Is there any more specific solution to show an error message if I make a mistake in the scss files?
gulp-sass node-sass
add a comment |
up vote
0
down vote
favorite
My question is, why I don't get any error message from the gulp tasks when I use wrong import path in my scss files?
I use this gulp tasks to compile and minify my sass files to their destination directory
// gulpfile.js
var gulp = require('gulp');
var sass = require('gulp-sass');
var frontendSassSrcDir = 'build/frontend/sass/**';
var frontendCssDestDir = 'public/css/';
var backendSassSrcDir = 'build/backend/sass/**';
var backendCssDestDir = 'public/css/';
gulp.task('frontend-style', function()
return gulp
.src(frontendSassSrcDir + '/*.scss')
.pipe(sass(outputStyle: 'compressed').on('error', sass.logError))
.pipe(gulp.dest(frontendCssDestDir))
);
gulp.task('backend-style', function()
return gulp.src(backendSassSrcDir + '/*.scss')
.pipe(sass(outputStyle: 'compressed').on('error', sass.logError))
.pipe(gulp.dest(backendCssDestDir));
);
gulp.task('default-watch', function()
gulp.watch('build/frontend/sass/**/*.scss', ['frontend-style']);
gulp.watch('build/backend/sass/**/*.scss', ['backend-style']);
);
here is the folder structure
- project-folder
- build
- backend
- sass
- backend.scss
- frontend
- sass
- frontend.scss
- node_modules
- public
- css
- backend.css
- frontend.css
gulpfile.js
Here is the wrong content of my scss file
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";
if I run this command in command line, it looks like it works, because I get this output, however it generates an empty css file
$ node_modules/gulp/bin/gulp.js frontend-style
[20:50:40] Using gulpfile /opt/workspace/www/bhajanBook/gulpfile.js
[20:50:40] Starting 'frontend-style'...
[20:50:40] Finished 'frontend-style' after 73 ms
why it doesn't give me the same error message like this command?
$ node_modules/sass/sass.js ./build/frontend/sass/frontend.scss ./public/css/frontend.css
Error: Can't find stylesheet to import.
@import "node_modules/bootstrap/scss/functions";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
build/frontend/sass/frontend.scss 1:9 root stylesheet
Running it in command line helped me to fix it
@import "./../../../node_modules/bootstrap/scss/functions";
@import "./../../../node_modules/bootstrap/scss/variables";
@import "./../../../node_modules/bootstrap/scss/mixins";
I learned that on('error', sass.logError) throws an error if I make a mistake in the gulpfile.js but it shouldn't be responsible for catching this error too?
Is there any more specific solution to show an error message if I make a mistake in the scss files?
gulp-sass node-sass
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My question is, why I don't get any error message from the gulp tasks when I use wrong import path in my scss files?
I use this gulp tasks to compile and minify my sass files to their destination directory
// gulpfile.js
var gulp = require('gulp');
var sass = require('gulp-sass');
var frontendSassSrcDir = 'build/frontend/sass/**';
var frontendCssDestDir = 'public/css/';
var backendSassSrcDir = 'build/backend/sass/**';
var backendCssDestDir = 'public/css/';
gulp.task('frontend-style', function()
return gulp
.src(frontendSassSrcDir + '/*.scss')
.pipe(sass(outputStyle: 'compressed').on('error', sass.logError))
.pipe(gulp.dest(frontendCssDestDir))
);
gulp.task('backend-style', function()
return gulp.src(backendSassSrcDir + '/*.scss')
.pipe(sass(outputStyle: 'compressed').on('error', sass.logError))
.pipe(gulp.dest(backendCssDestDir));
);
gulp.task('default-watch', function()
gulp.watch('build/frontend/sass/**/*.scss', ['frontend-style']);
gulp.watch('build/backend/sass/**/*.scss', ['backend-style']);
);
here is the folder structure
- project-folder
- build
- backend
- sass
- backend.scss
- frontend
- sass
- frontend.scss
- node_modules
- public
- css
- backend.css
- frontend.css
gulpfile.js
Here is the wrong content of my scss file
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";
if I run this command in command line, it looks like it works, because I get this output, however it generates an empty css file
$ node_modules/gulp/bin/gulp.js frontend-style
[20:50:40] Using gulpfile /opt/workspace/www/bhajanBook/gulpfile.js
[20:50:40] Starting 'frontend-style'...
[20:50:40] Finished 'frontend-style' after 73 ms
why it doesn't give me the same error message like this command?
$ node_modules/sass/sass.js ./build/frontend/sass/frontend.scss ./public/css/frontend.css
Error: Can't find stylesheet to import.
@import "node_modules/bootstrap/scss/functions";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
build/frontend/sass/frontend.scss 1:9 root stylesheet
Running it in command line helped me to fix it
@import "./../../../node_modules/bootstrap/scss/functions";
@import "./../../../node_modules/bootstrap/scss/variables";
@import "./../../../node_modules/bootstrap/scss/mixins";
I learned that on('error', sass.logError) throws an error if I make a mistake in the gulpfile.js but it shouldn't be responsible for catching this error too?
Is there any more specific solution to show an error message if I make a mistake in the scss files?
gulp-sass node-sass
My question is, why I don't get any error message from the gulp tasks when I use wrong import path in my scss files?
I use this gulp tasks to compile and minify my sass files to their destination directory
// gulpfile.js
var gulp = require('gulp');
var sass = require('gulp-sass');
var frontendSassSrcDir = 'build/frontend/sass/**';
var frontendCssDestDir = 'public/css/';
var backendSassSrcDir = 'build/backend/sass/**';
var backendCssDestDir = 'public/css/';
gulp.task('frontend-style', function()
return gulp
.src(frontendSassSrcDir + '/*.scss')
.pipe(sass(outputStyle: 'compressed').on('error', sass.logError))
.pipe(gulp.dest(frontendCssDestDir))
);
gulp.task('backend-style', function()
return gulp.src(backendSassSrcDir + '/*.scss')
.pipe(sass(outputStyle: 'compressed').on('error', sass.logError))
.pipe(gulp.dest(backendCssDestDir));
);
gulp.task('default-watch', function()
gulp.watch('build/frontend/sass/**/*.scss', ['frontend-style']);
gulp.watch('build/backend/sass/**/*.scss', ['backend-style']);
);
here is the folder structure
- project-folder
- build
- backend
- sass
- backend.scss
- frontend
- sass
- frontend.scss
- node_modules
- public
- css
- backend.css
- frontend.css
gulpfile.js
Here is the wrong content of my scss file
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";
if I run this command in command line, it looks like it works, because I get this output, however it generates an empty css file
$ node_modules/gulp/bin/gulp.js frontend-style
[20:50:40] Using gulpfile /opt/workspace/www/bhajanBook/gulpfile.js
[20:50:40] Starting 'frontend-style'...
[20:50:40] Finished 'frontend-style' after 73 ms
why it doesn't give me the same error message like this command?
$ node_modules/sass/sass.js ./build/frontend/sass/frontend.scss ./public/css/frontend.css
Error: Can't find stylesheet to import.
@import "node_modules/bootstrap/scss/functions";
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
build/frontend/sass/frontend.scss 1:9 root stylesheet
Running it in command line helped me to fix it
@import "./../../../node_modules/bootstrap/scss/functions";
@import "./../../../node_modules/bootstrap/scss/variables";
@import "./../../../node_modules/bootstrap/scss/mixins";
I learned that on('error', sass.logError) throws an error if I make a mistake in the gulpfile.js but it shouldn't be responsible for catching this error too?
Is there any more specific solution to show an error message if I make a mistake in the scss files?
gulp-sass node-sass
gulp-sass node-sass
asked Nov 10 at 20:01
Zoltán Süle
369416
369416
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53242913%2fwhy-gulp-doesnt-throw-an-error-if-the-import-path-is-wrong-in-a-sass-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown