Problem with accentuation in .js after concat and uglify in Gulp

3

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

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

After doing the concat and uglify in Gulp (which worked correctly), I had problems with accentuation in some system functionalities, for example the "DatePicker" of jQuery-ui.

Where should be typed " Schedule " is " Schedule ".

I've tried using " gulp-convert-encoding " and set it to ISO-8859-1, but it also did not work.

The section where I call the files, the concatenation and minifico follows:

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 left as UTF-8 and all accented characters are replaced with (?).

    
asked by anonymous 10.08.2015 / 16:26

2 answers

0

After several attempts, the only one that worked was converting each file to UTF8 before concat and minify. All accents worked correctly.

    
08.09.2015 / 13:12
1

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/'));
    
21.12.2015 / 01:45