@bemtools/gulp-extract-html-class

1.0.2 • Public • Published

NPM version Build Status

Extracts all classes from the html

Installation

npm install @bemtools/gulp-extract-html-class --save

Sample gulpfile.js

This file will give you a taste of what plugin does.

const gulp         = require('gulp');
const extractClass = require('@bemtools/gulp-extract-html-class');
const through      = require('through2');

function logClasses() {
	let PLUGIN_NAME = 'logClasses';

	return through.obj(function (file, enc, cb) {
		if (!file.contents.length) {
			this.push(null);
			cb(console.log(` ⚠ ${PLUGIN_NAME}: The file is empty `));
			return;
		}

		try {
			// the file has a custom value "classList"
			console.log(file.classList);
		} catch (err) {
			cb(console.log(` ⚠ ${PLUGIN_NAME}: Something went wrong: `, err));
			return;
		}

		this.push(file);
		cb();
	});
}

gulp.task('default', function () {
	return gulp.src('./src/templates/**/*.html')
		.pipe(extractClass())
		.pipe(logClasses())
		.pipe(gulp.dest('./dist/html/'));
});

Package Sidebar

Install

npm i @bemtools/gulp-extract-html-class

Weekly Downloads

0

Version

1.0.2

License

MIT

Unpacked Size

7.05 kB

Total Files

11

Last publish

Collaborators

  • yury.kopyl