gulp-include-sources

0.1.7 • Public • Published

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}" />'
    }
};

Package Sidebar

Install

npm i gulp-include-sources

Weekly Downloads

3

Version

0.1.7

License

ISC

Last publish

Collaborators

  • babieldev