gulp-assets icon indicating copy to clipboard operation
gulp-assets copied to clipboard

additional transformation configuration

Open jbouzekri opened this issue 10 years ago • 1 comments

Hi,

I have this use case where my template is using a simple template engine. I would like to use your plugin to extract css and js from this template.

however they are written with this syntax :

<script src="{{ url_for('static', filename='components/moment/moment.js') }}"></script>
<script src="{{ url_for('static', filename='components/moment-timezone/builds/moment-timezone-with-data.min.js') }}"></script>

My proposal in this pull request is to add 3 additionnal config parameters :

  • js_regex : allow to override the default regex
  • css_regex : allow to override the default regex
  • clean : allow to define a function to process/transform the extracted filename from the HTML tag.

It could be used like this :

assets({
        js: 'appJs',
        css: false,
        js_regex: /<script.*?src=(?:")(.*?)(?:")/g,
        clean: function(value) {
            return value.replace('\'', 'aaaaa');
       }
});

Please tell me if you would be willing to merge something like that. If yes, I will update my pull request with all additional documentation.

Thanks in advance

Regards

jbouzekri avatar Dec 11 '15 16:12 jbouzekri

@jbouzekri thanks for the awesome tweak! Can someone merge this? Ty!

TCB13 avatar Oct 03 '16 22:10 TCB13