shakyShane / bs-fullscreen-message

Fullscreen, in-browser error/success messages
19 stars 6 forks source link

Example for gulp-sass #6

Open martinherweg opened 7 years ago

martinherweg commented 7 years ago

I tried hard to get that working my-self but failed.

Could you please provide an example config to get it working with gulp-sass.

Thanks :)

griable commented 7 years ago

Hi @martinherweg,

Here's how I managed to make it. Please share if you manage to improve it in some way!

return gulp.src(config.styles.files)
      .pipe(sass())
      .on('data', function(err) {
        browserSync.sockets.emit('fullscreen:message:clear')
      })
      .on('error', function(err) {
        browserSync.sockets.emit('fullscreen:message', {
          title: "Sass Error:",
          body:  stripAnsi(err.messageFormatted),
          timeout: 100000
        })
        return sass.logError.call(this, err)
      })
      .pipe(gulp.dest(path.resolve(config.styles.dest)))
      .pipe(browserSync.stream());
martinherweg commented 7 years ago

Hello @griable,

thanks for your example, i'm now using webpack to compile css. But here is what I used to have a an error overlay without this plugin:

.pipe($.sass())
.on('error', function (err) {
      const error = `
      <div class="bs-fullscreen" 
      style="position: fixed; 
      top: 0; 
      left: 0; 
      width: 100%; 
      background: rgba(0,0,0,.85); 
      height: 
      100vh; 
      color: #e8e8e8; 
      text-align: left; 
      white-space: pre; 
      font-family: Menlo, Consolas, monospace; font-size: 13px; padding: 10px; line-height: 1.2;">
      <p><span style="background-color:#E36049; color:#fff; padding:2px 4px; border-radius: 2px; text-transform: uppercase">ERROR</span> in ${err.relativePath} on line ${err.line}:${err.column} </p>
      <p>${err.messageOriginal}</p>
    </div>
`;
      browserSync.notify(error, 100000);
      this.emit('end');
    })
griable commented 7 years ago

Hi @martinherweg,

Interesting implementation. I'm actually now using your version because of the flexibility it offers and currently unaccepted pull requests of this project (overflow issue).

Thanks a lot for sharing.