How to generate a hierarchical rule CSS using Gulp

Asked

Viewed 27 times

0

I have a father file called: /assets/hierarchy-file.scss, inside it I import the children files:

@import "./style_guide";
@import './default_styles';

@import './header';

// :::::::::: OS ARQUIVOS DAS PÁGINAS DEVEM COMEÇAR AQUI :::::::::: 

@import './home';

// ::::::::::::::::::::::::: TERMINA AQUI ::::::::::::::::::::::::: 

@import './footer';

Using Gulp only when I edit the parent file hierarchy-file.scss, the watch listens to it and picks up the changes from the children’s files. I would like when I change any of these children files, the watch recognizes that the parent file has been changed: hierarchy-file.scss, what I need to do?

var paths = {
css:[
    //assets_path+'./assets/css/*.scss',   
    //assets_path+'./assets/css/**/*.scss',   
    assets_path+'./assets/css/hierarchy-files.scss',  
  ]
}

gulp.task('css', function() {
  gulp.src(paths.css)
    .pipe(sass.sync().on('error', sass.logError))
    .pipe(concat('css.styles.css'))
    .pipe(gulpif(activeMinify, sass({outputStyle: 'compressed'})))
    .pipe(gulp.dest(public_path+'/css/'))
    .pipe(browserSync.stream())
  //  .on('end', done);
});

gulp.task('watch', function() {
  gulp.watch(paths.css, ['css']);
});
  • Just put them on the list of globs you pass to the second argument of gulp.watch, nay?

  • The idea is that Hierarchy-files is the compiled output I don’t want to generate the children files in the public folder. The children are nothing more than contents partials from the parent file... as I do it?

  • Yes, but if you put more files in the globs list it will not make any difference in the output, only when Gulp will run the process css...

  • But the watch is on browserSync, I mean, he’s compiling on the watch, let’s say, that I put ./assets/css/*.scss, [...]

  • [...] which means that when I edit any file inside this folder it goes through the watch, the problem is that it doesn’t compile the parent file, it just compiles the child file that I’m moving...

  • I wanted every time I touched one of the kids, the father was rewritten.

  • Maybe something like this: Gulp-css-globbing

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.