Skip to content

Treats JS script like a url to JS script #67

Description

@Maxim-Mazurok

I have the following template:

<!-- Hotjar Tracking Code -->
<script>
    (function (h, o, t, j, a, r) {
        h.hj =
            h.hj ||
            function () {
                (h.hj.q = h.hj.q || []).push(arguments);
            };
        h._hjSettings = { hjid: '%HJID%', hjsv: '%HJSV%' };
        a = o.getElementsByTagName('head')[0];
        r = o.createElement('script');
        r.async = 1;
        r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
        a.appendChild(r);
    })(window, document, 'https://static.hotjar.com/c/hotjar-', '.js?sv=');
</script>

And I was using this plugin like so:

function createCopyHTMLTask(env) {
    return gulp
        .src(html, { base: './' })
        .pipe(
            gulpHtmlReplace({
                hotJar: fs.readFileSync(hotJarTemplatePath, 'utf-8')
            }),
        )
        .pipe(gulp.dest(distPath));
}

And because of this logic:
https://github.com/VFK/gulp-html-replace/blob/HEAD/lib/block.js#L65-L69

My script was added like this:

<script src="<!-- Hotjar Tracking Code --> <script> (function (h, o, t, j, a, r) { h.hj =...

Which is obviously not right

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions