posthtml-classes
posthtml-classes copied to clipboard
Bug when using glob to match html files
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
Hi @ierhyna! The plugin works as expected.
- If the overwrite option is enabled (overwrite: true) then the plugin extracts classnames and overwrite the filePath file so that at the end of this file will be overwritten with classes of the last html
- If the overwrite option is disabled (overwrite: false) then the plugin extracts classnames to separate files.
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?
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.
Hi @ierhyna! I can try to realize this logic. Should I remove duplicate classes, which will be inserted in the file?
@rajdee, if it's possible to insert only unique classes it would be nice 👍 Thanks in advance 😃