I included gulp-uncss:
var uncss = require('gulp-uncss');
Then I added its function to the styles
task:
gulp.task('styles', () => {
return gulp.src('app/styles/*.scss')
.pipe($.plumber())
.pipe($.sourcemaps.init())
.pipe($.sass.sync({
outputStyle: 'expanded',
precision: 10,
includePaths: ['.']
}).on('error', $.sass.logError))
.pipe($.autoprefixer({browsers: ['last 1 version']}))
.pipe($.sourcemaps.write())
.pipe(uncss({
html: ['dist/index.html']
}))
.pipe(gulp.dest('.tmp/styles'))
.pipe(reload({stream: true}));
});
But, it's not working because the index.html
hasn't been generated yet.
Given yeoman generator gulp-webapp's gulpfile, how is it possible to make uncss process the main.css
file upon build?