How to resolve " Unexpected character '#' " using gulp-terser to minify files

Viewed 202

I'm using this code to minify all my js files of a project in one file:

var gulp = require('gulp');
var terser = require('gulp-terser');
var gp_concat = require('gulp-concat');
const { dest } = require("gulp");

gulp.task('concat', function () {
    return gulp.src('/home/samyrharade/Documents/Script-Mailchimp/**/*.js')
        .pipe(gp_concat('concat.js'))
        .pipe(gulp.dest('/home/samyrharade/Documents/Test/Concat'))
});


gulp.task('minify', function (){
    return gulp.src('/home/samyrharade/Documents/Test/Concat/concat.js')
        .pipe(terser())
        .pipe(dest('/home/samyrharade/Documents/Test/Minifie'))
})

But I have this error that come when I'm using gulp minify:

[14:12:01] Using gulpfile ~/Documents/Script-Minifier/gulpfile.js
[14:12:01] Starting 'minify'...
[14:12:01] 'minify' errored after 341 ms
[14:12:01] Error in plugin "terser"
Message:
    Unexpected character '#'
Details:
    domainEmitter: [object Object]
    domain: [object Object]
    domainThrown: false

I can concatenate all my files in one but I'm not able to minify them.

Anyone know how to solve it ? Or is there any other way to minify all files ? I've tried with uglify but I'm using ES6 in my project so it's not able to minify files.

0 Answers
Related