Gulp JS text imports
Gulp plugin to inline import name from './file.html';
as const name = "content of file.html file";
, with support for content transformations
Install
npm install --save-dev gulp-js-text-imports
Usage
const gulp = ;const importsInliner = ;const htmlMinify = minify; gulp
Config
Gulp JS text imports plugin supports the following config options:
acceptedExtensions: ['html', 'css']
Files with listed extensions will be inlined. Unles a coresponding handler is defined for an extension, the content of a file is escaped and inlined into the source file.
handlers: { extension: (content, path, callback) => callback(err, transformedContent) }
Optional handler functions to transform content prior to inlining, such as minifying HTML, and processing SASS.
parserOptions: { ecmaVersion: 7, sourceType: 'module' }
Acorn parser options. This plugin is meant to work with ES6 module imports, therefore changing the sourceType
option most likey won't work.