UNPKG

gulp-include-sources

Version:

Includes source files listed in HTML comments

36 lines (26 loc) 1.11 kB
This module helps you to include files, that you've listed in a simple HTML comment. New files will be generated with the correct tags and files. It's something like grunt-include-source Example gulp task: const includeSource = require("gulp-include-sources"); gulp.task("default", function(){ return gulp.src("./test/src/*.html") .pipe(includeSource()) .pipe(gulp.dest("./test/dest/"));}); }` That's inside /src/index.html: `<!-- include: "type": "js", "files": ["scripts/test.js"] -->` That's going to be generated (if the files exist): `<script src='scripts/test.js'></script>'` When listed files are not found, the comment won't be replaced and you will get a warning in the console. Default configuration: const DEFAULT_OPTIONS = { includesDir: "./", prefix: "<!-- ", suffix: " -->", debug: false, templates: { "js": '<script src="{filePath}"></script>', "css": '<link rel="stylesheet" type="text/css" href="{filePath}" />' } };