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?










share|improve this question

























    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?










    share|improve this question























      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?










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 10 at 20:01









      Zoltán Süle

      369416




      369416



























          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',
          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
          );



          );













           

          draft saved


          draft discarded


















          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















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          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





















































          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







          這個網誌中的熱門文章

          What does pagestruct do in Eviews?

          Dutch intervention in Lombok and Karangasem

          Channel Islands