php – Problem with accent in .js after concat and ugliify in Gulp

Question:

I'm trying to optimize the website of the agency where I work and I'm having problems after concatenating and minifying the javascripts.

Our Apache server uses ISO-8859-1 and all my files in PHPStorm are configured in this same charset.

After doing concat and uglify in Gulp (which worked correctly), I had problems with accenting some system features, for example jQuery-ui's "DatePicker".

Where should be written "Time" is "Hor? River."

I've tried using " gulp-convert-encoding " and setting it to ISO-8859-1, but it didn't work either.

Here is the excerpt where I call the files, concatenation and minific:

var js  = [
    './msg/js/jquery-1.10.1.min.js',
    './placeholder/jquery-placeholder.js',
    './msg/js/msg.js',
    './enviarArquivo/js/ajaxupload.3.5.js',
    './funcoes/funcoes.js',
    '../../../padroes/interface/scripts/shadowbox.js', // Padrão de interfaces
    './calendario/jquery-ui-1.10.3.custom.js',
    './calendario/jquery-ui-timepicker-addon.js',
    './combobox/chosen.jquery.js',
];

gulp.task('minify-js', function () {
    gulp.src(js)
        .pipe(concat('script.min.js'))
        .pipe(convertEncoding({to: 'ISO-8859-1'}))
        .pipe(uglify())
        .pipe(gulp.dest('../pages/template/js/dist/'))
        .pipe(notify('Javascript compilado e minificado!'));
});

I saw that when I finished compiling, the script.min.js file is UTF-8 and all accented characters are replaced by (?).

Answer:

if you use convertEncoding with from and to, all work fine:

 gulp.src('tmp/js/lib/**/*.js')
     //.pipe(stripCode({}))
     .pipe(convertEncoding({from: 'ISO-8859-15', to: 'UTF-8'}))
     .pipe(uglify())
     .pipe(convertEncoding({from: 'UTF-8', to: 'ISO-8859-15'}))
     .pipe(gulp.dest('dist/js/'));
Scroll to Top
AllEscort