A
A
AlexeyMoshkin2015-10-16 15:23:46
JavaScript
AlexeyMoshkin, 2015-10-16 15:23:46

How to fix grunt-contrib-uglify "Unexpected character" error?

When building a project, warning:

>> Uglifying source app/chrome/scripts/shared/common.js failed.
Warning: Uglification failed.
Unexpected character ' ` '. 
Line 582 in app/chrome/scripts/shared/common.js
 Use --force to continue.

The line that caused the warning:
var preloader = `<div id="preload-bar" style="width: 352px; >hello world!</div>`;

Updating grunt-contrib-uglify didn't help.
Adding a line to the soil file
grunt.file.defaultEncoding = 'utf-8';
didn't help either.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AlexeyMoshkin, 2015-10-20
@AlexeyMoshkin

Actually you need to convert your es6 code to es5. This can be done by adding grunt tasks such as grunt-es6-transpiler or grunt-babel
And more on es6-tools .

D
Denis Ineshin, 2015-10-16
@IonDen

This is an invalid type of quotes. Single ones like this: '
+ you missed one double quote in style

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question