vigetlabs / blendid

A delicious blend of gulp tasks combined into a configurable asset pipeline and static site builder
MIT License
4.97k stars 683 forks source link

Watch/reload stops working on .css files when using alternative task #506

Closed codylindley closed 6 years ago

codylindley commented 6 years ago

I'm using an alternative task for stylesheets:

stylesheets: {
    alternateTask: function(gulp, PATH_CONFIG, TASK_CONFIG) {
      // PostCSS task instead of Sass
      return function() {
        const plugins = [
            autoprefixer({browsers: ['> 5%']}),
            cssnano()
        ]
        return gulp.src(path.resolve(process.env.PWD, PATH_CONFIG.src, PATH_CONFIG.stylesheets.src, '**/*.css'))
            .pipe(postcss(plugins))
            .pipe(gulp.dest(path.resolve(process.env.PWD, PATH_CONFIG.dest, PATH_CONFIG.stylesheets.dest)))
      }
    }
  },

But when I do this the browser auto reload upon .css file changes stops working.

benjtinsley commented 6 years ago

@codylindley sorry for the delay, i am currently looking into a fix for this, however in the meantime, i notice you have .css as the extension that the src pattern looks for. can you verify you are, in fact, using .css as the extension and not .pcss or something else in your source directory?

diegotoral commented 6 years ago

I'm also using an alternative task for stylesheets but facing a different problem. In my case the browser auto reloads upon changes to .scss files but fails to load/request the file with the following message.

Failed to load resource: the server responded with a status of 404 (Not Found)
:3001/assets/stylesheets/app.css Failed to load resource: the server 
stylesheets: {
    publicPath: '/assets/stylesheets',
    alternateTask: function(gulp, PATH_CONFIG, TASK_CONFIG) {
      return function() {
        var plugins = [
          math,
        ];

        var paths = {
          src: path.resolve(process.env.INIT_CWD, PATH_CONFIG.src, PATH_CONFIG.stylesheets.src,'**/*.{' + TASK_CONFIG.stylesheets.extensions + '}'),
          dest: path.resolve(process.env.INIT_CWD, PATH_CONFIG.dest, PATH_CONFIG.stylesheets.dest),
        };

        return gulp.src(paths.src)
          .pipe(gulpif(!global.production, sourcemaps.init()))
          .pipe(postcss(plugins))
          .on('error', error => console.log(error))
          .pipe(gulp.dest(paths.dest))
          .pipe(browserSync.stream());
      };
    }
  },