 # experiments
 # =================================================================                      
 
+# Agressive css clean
+condition = {'build/blog/**/*.html'}
 
 gulp.task "css_clean", ->
-  return gulp.src('build/css/main.css')
+  return gulp.src('build/css/*.css')
+    .pipe(gulpignore.exclude(condition))
     .pipe(uncss(
-      html: ['build/**/*.html'],
+      html: ['build/**/*.html']
+      report: true
       ignore: [
-                new RegExp('^.no-touch.*'),
-                new RegExp('\.Header*(.)\S+'),
-                new RegExp('^.js-side-nav*'),
-                new RegExp('^.side-nav*'),
+                new RegExp('^.no-touch.*')
+                new RegExp('\.Header*(.)\S+')
+                new RegExp('^.js-side-nav*')
+                new RegExp('^.side-nav*')
                 new RegExp('\.logotype*(.)\S+')
                 new RegExp('\.cart-*(.)\S+')
                 new RegExp('\.no-touch*(.)\S+')

                new RegExp('\.Aligner-*(.)\S+')
                new RegExp('\.TechSpecs-*(.)\S+')
                ]
      timeout: 5000
                ))
      .pipe(gulp.dest('build/css'))


gulp.task "purifycss", ->
  return gulp.src('build/css/main.css')
    .pipe(purifycss(['build/**/*.html','build/**/*.js']))
    .pipe(mincss({compatibility: 'ie8'}))
    .pipe(gulp.dest('build/css'))

gulp.task "checkcss", ->
  return gulp.src(['build/css/main.css','build/**/*.html'])
    .pipe(checkcss())


gulp.task 'cleaned', ->
  # preview with browserSync

  gulp.watch "./assets/stylus/**/*.styl", ['css:build:preview']
  gulp.watch "./templates/**/*.jade", ['preview:jade']
  gulp.watch "./contents/**/*.md", ['preview:md']

# =================================================================                      
# tools
# =================================================================  

gulp.task "checkcss", ->
  return gulp.src(['build/css/main.css','build/**/*.html'])
    .pipe(checkcss())



