Плагин
Шаблон
"use strict";
const through = require("through2");
const PluginError = require("plugin-error");
const PLUGIN_NAME = "name";
/**
* @param {Object} [options]
*
*
*/
const gulpSourceToHTML = (pluginOptions = {}) => {
return through.obj((file, _, callback) => {
if (file.isNull()) {
return callback(null, file);
}
if (file.isStream()) {
return callback(new PluginError(PLUGIN_NAME, "Streaming not supported"));
}
const defaultOptions = { rootpath: file.base, extensions: [".jpg", ".png", ".jpeg", ".JPG", ".PNG", ".JPEG"] };
const options = { ...defaultOptions, ...pluginOptions };
(async () => {
try {
file.contents = Buffer.from(newData);
callback(null, file);
} catch (err) {
callback(new PluginError(PLUGIN_NAME, err));
}
})();
});
};
module.exports = gulpSourceToHTML;
Дополнительные материалы
Last updated