0

I have a problem with my gulp file. It is compile all correctly, except the strings with backticks. Is there some package or solution to fix that?

This is my gulpfile.js code:

const gulp = require('gulp');
const concat = require('gulp-concat')
const uglify = require('gulp-uglify');

gulp.task('scripts', function() {
    return gulp.src([
            'script.js'
        ])
        .pipe(concat('script.min.js'))
        .pipe(uglify())
        .pipe(gulp.dest('js/min/'))
});

And the result is:

...const t=document.createElement("div");t.innerHTML=`
<div class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-body">
                <p>${e.text}</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary">${e.accept}</button>
            </div>
        </div>
    </div>
</div>`,document.querySelector("body").appendChild(t)}...
Sones1
  • 123
  • 10
  • 1
    Worth trying the package `https://www.npmjs.com/package/gulp-terser` which is more up-to-date with newer javascript than `gulp-uglify`. Although one advantage of template literals is to preserve newlines within strings so maybe nothing will happen. But you shouldn't be using `gulp-uglify` anyhow. – Mark Mar 18 '22 at 19:03
  • @Mark this could be the anwer for this issue because the problem has dissapear with gulp-terser – Sones1 Mar 21 '22 at 07:51

0 Answers0