D
D
drtvader2017-05-25 07:54:55
gulp.js
drtvader, 2017-05-25 07:54:55

Where is the error in the task?

I'm trying to set up a gulp-uncss task , but for some reason I'm getting an error.

'use strict';

const $                    = require('gulp-load-plugins')();
const gulp                 = require('gulp');
const config               = require('../../../config');
const lessUncss            = require('gulp-uncss');
const lessPluginAutoPrefix = require('less-plugin-autoprefix');
const lessPluginCleanCSS   = require('less-plugin-clean-css');

var autoprefixer = new lessPluginAutoPrefix(config.autoprefixer),
    cleancss     = new lessPluginCleanCSS({ advanced: true });
    uncss        = new lessUncss,

module.exports = function(options) {
    return config.wrapPipe(function(success, error) {
        return gulp.src(config.less.src)
            .pipe($.less({
                plugins: [autoprefixer, cleancss],
            }).on('error', error))
            .pipe($.csscomb())
            .pipe($.csso())
            .pipe(uncss({
                html: ['/build/*.html']
            }))
            .pipe(gulp.dest(config.less.dest));
    });
};

What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
B
Bogdan, 2017-05-25
@bogdan_uman

You have some mixture of bulldog (Gulp) and rhinohorm (webpack) here.
Here is a clean Gulp4

sass = require 'gulp-sass'
slim = require 'gulp-slim'
coffee = require 'gulp-coffee'

notify = require 'gulp-notify'
plumber = require 'gulp-plumber'

connect = require 'gulp-connect'
gulp = require 'gulp'

paths =
  app: 'app'
  sass: 'sass/**/*.scss'
  slim: 'slim/**/*.slim'
  coffee: 'coffee/**/*.coffee'
  js: 'js/**/*.js'


########################################
########################################



tsass = ->
  gulp.src paths.sass
    .pipe plumber { errorHandler: notify.onError message: "<%= error.message %>", title: "Ошибка"  }
    .pipe sass outputStyle: 'expanded'
    .pipe gulp.dest paths.app
    .pipe connect.reload( )
########################################
tslim = ->
  gulp.src paths.slim
    .pipe plumber { errorHandler: notify.onError message: "<%= error.message %>", title: "Ошибка"  }
    .pipe slim pretty: true
    .pipe gulp.dest paths.app
    .pipe connect.reload( )
########################################
tjs = ->
  gulp.src paths.js
    .pipe plumber { errorHandler: notify.onError message: "<%= error.message %>", title: "Ошибка"  }
    .pipe gulp.dest paths.app
    .pipe connect.reload( )
########################################
tcoffee = ->
  gulp.src paths.coffee
    .pipe plumber { errorHandler: notify.onError message: "<%= error.message %>", title: "Ошибка"  }
    .pipe coffee bare: true
    .pipe gulp.dest paths.app
    .pipe connect.reload( )
########################################
twatch = ->
  gulp.watch paths.sass, tsass
  gulp.watch paths.slim, tslim
  gulp.watch paths.coffee, tcoffee
  gulp.watch paths.js, tjs
########################################
tconnect = ->
  connect.server
    root: paths.app
    port: 8888
    livereload: true
########################################

watch = gulp.parallel tconnect,
  gulp.series( gulp.parallel( tslim, tsass, tcoffee, tjs ), twatch )

gulp.task 'default', watch

E
Egor Zhivagin, 2017-05-25
@Krasnodar_etc

module.exports in gulp - is it legal at all? I haven't seen this yet.
Well, at least I don't see the gulp task. And what error does it output?

D
drtvader, 2017-05-26
@drtvader

Disabled ignore in node_modules\gulp-uncss\index.js file
Line 14: // options.ignoreSheets = [/\s*/];
Gathered, but deletes also the necessary styles too.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question