Why gulp doesn't throw an error if the import path is wrong in a sass file?
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 |
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 |
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
379417
379417
add a comment |
add a comment |
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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