Skip to content

Ability to control syntax #65

@Grawl

Description

@Grawl

Hi! Awesome plugin, love it very much! So simple include/require instead of all this bullshit with Webpack or Browserify, just like in Sass 😅

I have an idea: like in gulp-inject#optionsstarttag, I want to control the syntax of how I use gulp-include.

For example:

.pipe(include({
    template: {
        js: (type, file)=> {
            return `//=${type} ${file}`
            // returns //=require "file.js"
            // or //=include 'file.js'
        }
    }
}))

This will be a default setting for JS files.

I want to use require()-like syntax to allow my editor to hint me relative paths by dropdown when it's uncommented, so I write require(''), hit Ctrl+Space and editor opens a popup with matched files:

2016-05-17 12 58 15

And then I comment it and add = symbol, so I have this:

//=require('../../node_modules/jquery/dist/jquery.js')

And I sure that I have the right path.

But now every time I add //require I have to remove ( and ) to make it work.

If there will be an option to modify this comment template, I will add parentheses to it:

.pipe(include({
    template: {
        js: (type, file)=> {
            return `//=${type} (${file})`
        }
    }
}))

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions