rajdee / posthtml-classes

PostHTML-plugin to retrieve a list of classes from html
MIT License
21 stars 0 forks source link

Bug when using glob to match html files #4

Open ierhyna opened 8 years ago

ierhyna commented 8 years ago

Hi, I suppose there is a bug when using glob in gulp.src() to match multiple html files.

I've got 75 html files, and some CSS classes are the same, but there are unique CSS classes in every html file too. I use gulp.src('*.html') to match every html file, but the plugin doesn't copy classes from every file.

Looks like the plugin only gets classes from the last file in array.

My gulpfile.js is as following:

var gulp = require('gulp'),
    posthtml = require('gulp-posthtml');

gulp.task('default', function () {
  return gulp.src('*.html')
    .pipe(posthtml([
      require('posthtml-classes')({
        fileSave: true,
        filePath: './classList.css',
        overwrite: true,
        eol: '\n',
        nested: true,
        elemPrefix: '__',
        modPrefix: '--',
        modDlmtr: '-',
        curlbraces: true
      })
    ]));
});

Gulp v3.9.1 Node v4.4.3 npm v2.15.1

rajdee commented 8 years ago

Hi @ierhyna! The plugin works as expected.

I think you expect that when this option is enabled (overwrite: true) all the extracted classes have been appended to the end of the file. Is it so?

ierhyna commented 8 years ago

Hi @rajdee, thanks for the answer.

I'd like to grab all the classes from every HTML file, and put them all into single CSS file. If that's possible, how can I do it?

If it isn't possible yet, I could try to develop this feature.

rajdee commented 8 years ago

Hi @ierhyna! I can try to realize this logic. Should I remove duplicate classes, which will be inserted in the file?

ierhyna commented 8 years ago

@rajdee, if it's possible to insert only unique classes it would be nice 👍 Thanks in advance 😃