Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uglify JS Unexpected token operator <<->>, expected punc <<: >>

When i try to uglify and concat using Grunt uglify js in the follwing line ,

ember-data: 'ember'

uglification fails. How to let uglifyjs skip checking for <<->>?

grunt config :

module.exports = function(grunt){
grunt.initConfig({
    pkg : grunt.file.readJSON('package.json'),
    concat : {
        options : {
            seperator :  ';'
        },
        dist : {
            src : ['js/*.js'],
            dest : 'output.min.js'
        }
    },
    uglify : {
        options : {
            banner : '/*! <%=grunt.template.today("dd-mm-yyyy")%> */\n'
        },
        dist : {
            files : {
                'dist/output.min.js' : ['<%= concat.dist.dest%>']
            }
        }
    },


});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');

grunt.registerTask('default', ['concat', 'uglify']);

}

and my config.js is

require.config({
baseUrl: 'js',
shim: {
    ember: {
        deps: ['handlebars', 'jquery'],
        exports: 'Ember'
    },
    ember-data: 'ember',
    bootstrap: 'jquery',
    handlebars: ['Handlebars']
},
paths: {
    'App': '\js\application\app',
    'models': '',
    'views': '',
    'controllers': '',
    'templates': '',

    /*LIBRARIES*/
    'jquery': '\libs\jquery\jquery',
    'handlebars': '\libs\handlebars\handebars-1.1.2',
    'ember': '\libs\ember\ember-1.2.0',
    'ember-data' : '\libs\ember\ember-data'
    'bootstrap': '\libs\bootstrap\bootstrap.min.js',

    /*REQUIRE JS PLUGINS*/
    'text': '\libs\require\require plugins\text',
    'hbs': '\libs\require\require plugins\hbs',
    'domReady': '\libs\require\require plugins\domReady'
},
hbs: {
    disableI18n: true,
    templateExtension: 'hbs'
},

'App',
'store',
'router'    

});

Thanks

like image 405
Bachan-user3143666 Avatar asked Jan 18 '14 00:01

Bachan-user3143666


Video Answer


1 Answers

This is not an uglify issue.

This part of your JavaScript file is simply invalid:

shim: {
ember: {
    deps: ['handlebars', 'jquery'],
    exports: 'Ember'
},
ember-data: 'ember',
bootstrap: 'jquery',
handlebars: ['Handlebars']
},

You need to change ember-data: 'ember' to 'ember-data': 'ember'. Mind the quotes!

like image 84
Mangled Deutz Avatar answered Sep 24 '22 12:09

Mangled Deutz