【问题标题】:bower_concat SyntaxError: missing ) after argument listbower_concat SyntaxError: missing ) 在参数列表之后
【发布时间】:2021-10-21 08:22:22
【问题描述】:
Loading "Gruntfile.js" tasks...ERROR
SyntaxError: missing ) after argument list
Warning: Task "default" not found. Use --force to continue.
Aborted due to warnings.
module.exports = function (grunt) {
    
    grunt.initConfig({
        dirs: {
            buildPath: 'builds/development/resource',
            javaServerResourcePath: 'D:/JES_SOURCE_CODE/Main/Sales/WebContent/resource'
        },
        concat: {
            js: {
                src: ['source/app/app.js', 'source/assets/js/*.js'],
                dest: '<%= dirs.buildPath %>/sales/assets/js/main.js'
            },
            css: {
                
            },
                src: [
                    'source/assets/css/fonts.css',
                    'source/assets/css/fuelux.css',
                    'source/assets/css/style.css',
                    'source/assets/css/growl.css'
                ],
                dest: '<%= dirs.buildPath %>/sales/assets/css/main.css'
            }
        },
        bower_concat: {
            all: {
                dest:{'<%= dirs.buildPath %>/sales/assets/js/_lib.js'},
                cssDest:{'<%= dirs.buildPath %>/sales/assets/css/_lib.css'},
                mainFiles: {
                    'font-awesome': ['css/font-awesome.css'],
                    'jquery-ui': ['themes/smoothness/jquery-ui.css', 'jquery-ui.js'],
                    'bootstrap': ['dist/js/bootstrap.js', 'dist/css/bootstrap.css'],
                    'angular-ui-growl': ['src/growl.js', 'css/growl.css']
                },
                dependencies: {
                    'angular': 'jquery',
                    'angular-bootstrap': 'angular',
                    'bootstrap': 'angular-bootstrap',
                    'jquery-ui': 'bootstrap'
                },
                bowerOptions: {
                    relative: false
                }
            }
        },
        clean: {
            build: {
                src: ["<%= dirs.buildPath %>/*.html", "<%= dirs.buildPath %>/sales/app/*", "<%= dirs.buildPath %>/sales/assets/*"]
            }
        },
        copy: {
            appHtml: {
                expand: true,
                cwd: 'source/',
                src: ['*.html'],
                dest: '<%= dirs.buildPath %>/sales'
            },
            appImages: {
                expand: true,
                cwd: 'source/assets/',
                src: ['images/**'],
                dest: '<%= dirs.buildPath %>/sales/assets/'
            },
            angularApp: {
                expand: true,
                cwd: 'source/',
                src: ['app/**', '!app/templates/**', '!app/*.js'],
                dest: '<%= dirs.buildPath %>/sales/'
            },
            bootstrapFonts: {
                expand: true,
                cwd: 'bower_components/bootstrap/',
                src: ['fonts/*.*'],
                dest: '<%= dirs.buildPath %>/sales/assets/'
            },
            fontAwesomeFonts: {
                expand: true,
                cwd: 'bower_components/font-awesome/',
                src: ['fonts/*.*'],
                dest: '<%= dirs.buildPath %>/sales/assets/'
            },
            jqueryUIImages: {
                expand: true,
                cwd: 'bower_components/jquery-ui/themes/smoothness/',
                src: ['images/**'],
                dest: '<%= dirs.buildPath %>/sales/assets/css/'
            },
            toJavaServer: {
                expand: true,
                cwd: '<%= dirs.buildPath %>/',
                src: ['sales/**', '!sales/*.html'],
                dest: '<%= dirs.javaServerResourcePath %>'
            }
        },
        html2js: {
            options: {
                base: 'source',
                htmlmin: {
                    removeComments: true,
                    collapseWhitespace: true
                }
            },
            main: {
                src: ['source/app/**/*.tpl.html'],
                dest: '<%= dirs.buildPath %>/sales/app/templates/templates.js'
            }
        },
        ngAnnotate: {
            options: {
                singleQuotes: true
            },
            app: {
                files: [
                    {
                        expand: true,
                        cwd: '<%= dirs.buildPath %>/sales',
                        src: ['app/controllers/*.js', 'app/services/*.js'],
                        dest: '<%= dirs.buildPath %>/sales/'
                    }
                ]
            },
            lib:{
                files: [
                    {
                        expand: true,
                        cwd: '<%= dirs.buildPath %>/sales',
                        src: ['assets/js/*.js'],
                        dest: '<%= dirs.buildPath %>/sales/'
                    }
                ]
            }
        },
        uglify: {
            options: {
                ASCIIOnly: true,
                compress: {
                    drop_console: true
                }
            },
            libs: {
                files: [{
                        expand: true,
                        cwd: '<%= dirs.buildPath %>/sales/assets/js',
                        src: ['**/*.js', '!*.min.js'],
                        dest: '<%= dirs.buildPath %>/sales/assets/js'
                    }]
            },
            app: {
                files: [{
                        expand: true,
                        cwd: '<%= dirs.buildPath %>/sales',
                        src: ['app/**/*.js', '!*.min.js'],
                        dest: '<%= dirs.buildPath %>/sales'
                    }]
            }
        },
        cssmin: {
            target: {
                files: [{
                        expand: true,
                        cwd: '<%= dirs.buildPath %>/sales/assets/css',
                        src: ['*.css', '!*.min.css'],
                        dest: '<%= dirs.buildPath %>/sales/assets/css'
                    }]
            }
        },
        connect: {
            server: {
                options: {
                    hostname: 'localhost',
                    port: 3000,
                    base: '<%= dirs.buildPath %>/',
                    livereload: true
                }
            }
        },
        watch: {
            options: {
                spawn: false,
                livereload: true
            },
            scripts: {
                files: ['source/**'],
                tasks: ['clean', 'html2js', 'concat', 'bower_concat', 'copy']
            }
        },
        // grunt-open will open your browser at the project's URL
        open: {
            server: {
                // Gets the port from the connect configuration
                path: 'http://localhost:8090/Sales'
            },
            local: {
                // Gets the port from the connect configuration
                path: 'http://localhost:<%= connect.server.options.port%>'

            }
        }

    });

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-open');
    grunt.loadNpmTasks('grunt-bower-concat');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-ng-annotate');
    grunt.loadNpmTasks('grunt-html2js');
    
    grunt.registerTask('test', ['clean', 'tomcat_deploy', 'nodeunit']);
    grunt.registerTask('default', ['clean', 'html2js', 'concat', 'bower_concat', 'copy', 'open:local', 'connect', 'watch']);
    grunt.registerTask('serve', ['clean', 'html2js', 'concat', 'bower_concat', 'copy', 'open:server', 'watch']);
    grunt.registerTask('prod', ['clean', 'html2js', 'concat', 'bower_concat', 'copy','ngAnnotate','uglify', 'copy:toJavaServer', 'cssmin', 'open:server', 'watch']);
};

【问题讨论】:

    标签: javascript gruntjs


    【解决方案1】:

    您的行中有 JSON 错误:
    23(一个“}”太多),
    27 和 28(“{}”返回一个对象而不是字符串,因此“{}”中必须有一个对象而不仅仅是一个字符串)

    module.exports = function (grunt) {
        
        grunt.initConfig({
            dirs: {
                buildPath: 'builds/development/resource',
                javaServerResourcePath: 'D:/JES_SOURCE_CODE/Main/Sales/WebContent/resource'
            },
            concat: {
                js: {
                    src: ['source/app/app.js', 'source/assets/js/*.js'],
                    dest: '<%= dirs.buildPath %>/sales/assets/js/main.js'
                },
                css: {
                    
                },
                    src: [
                        'source/assets/css/fonts.css',
                        'source/assets/css/fuelux.css',
                        'source/assets/css/style.css',
                        'source/assets/css/growl.css'
                    ],
                    dest: '<%= dirs.buildPath %>/sales/assets/css/main.css'
            },
            bower_concat: {
                all: {
                    dest:'<%= dirs.buildPath %>/sales/assets/js/_lib.js',
                    cssDest:'<%= dirs.buildPath %>/sales/assets/css/_lib.css',
                    mainFiles: {
                        'font-awesome': ['css/font-awesome.css'],
                        'jquery-ui': ['themes/smoothness/jquery-ui.css', 'jquery-ui.js'],
                        'bootstrap': ['dist/js/bootstrap.js', 'dist/css/bootstrap.css'],
                        'angular-ui-growl': ['src/growl.js', 'css/growl.css']
                    },
                    dependencies: {
                        'angular': 'jquery',
                        'angular-bootstrap': 'angular',
                        'bootstrap': 'angular-bootstrap',
                        'jquery-ui': 'bootstrap'
                    },
                    bowerOptions: {
                        relative: false
                    }
                }
            },
            clean: {
                build: {
                    src: ["<%= dirs.buildPath %>/*.html", "<%= dirs.buildPath %>/sales/app/*", "<%= dirs.buildPath %>/sales/assets/*"]
                }
            },
            copy: {
                appHtml: {
                    expand: true,
                    cwd: 'source/',
                    src: ['*.html'],
                    dest: '<%= dirs.buildPath %>/sales'
                },
                appImages: {
                    expand: true,
                    cwd: 'source/assets/',
                    src: ['images/**'],
                    dest: '<%= dirs.buildPath %>/sales/assets/'
                },
                angularApp: {
                    expand: true,
                    cwd: 'source/',
                    src: ['app/**', '!app/templates/**', '!app/*.js'],
                    dest: '<%= dirs.buildPath %>/sales/'
                },
                bootstrapFonts: {
                    expand: true,
                    cwd: 'bower_components/bootstrap/',
                    src: ['fonts/*.*'],
                    dest: '<%= dirs.buildPath %>/sales/assets/'
                },
                fontAwesomeFonts: {
                    expand: true,
                    cwd: 'bower_components/font-awesome/',
                    src: ['fonts/*.*'],
                    dest: '<%= dirs.buildPath %>/sales/assets/'
                },
                jqueryUIImages: {
                    expand: true,
                    cwd: 'bower_components/jquery-ui/themes/smoothness/',
                    src: ['images/**'],
                    dest: '<%= dirs.buildPath %>/sales/assets/css/'
                },
                toJavaServer: {
                    expand: true,
                    cwd: '<%= dirs.buildPath %>/',
                    src: ['sales/**', '!sales/*.html'],
                    dest: '<%= dirs.javaServerResourcePath %>'
                }
            },
            html2js: {
                options: {
                    base: 'source',
                    htmlmin: {
                        removeComments: true,
                        collapseWhitespace: true
                    }
                },
                main: {
                    src: ['source/app/**/*.tpl.html'],
                    dest: '<%= dirs.buildPath %>/sales/app/templates/templates.js'
                }
            },
            ngAnnotate: {
                options: {
                    singleQuotes: true
                },
                app: {
                    files: [
                        {
                            expand: true,
                            cwd: '<%= dirs.buildPath %>/sales',
                            src: ['app/controllers/*.js', 'app/services/*.js'],
                            dest: '<%= dirs.buildPath %>/sales/'
                        }
                    ]
                },
                lib:{
                    files: [
                        {
                            expand: true,
                            cwd: '<%= dirs.buildPath %>/sales',
                            src: ['assets/js/*.js'],
                            dest: '<%= dirs.buildPath %>/sales/'
                        }
                    ]
                }
            },
            uglify: {
                options: {
                    ASCIIOnly: true,
                    compress: {
                        drop_console: true
                    }
                },
                libs: {
                    files: [{
                            expand: true,
                            cwd: '<%= dirs.buildPath %>/sales/assets/js',
                            src: ['**/*.js', '!*.min.js'],
                            dest: '<%= dirs.buildPath %>/sales/assets/js'
                        }]
                },
                app: {
                    files: [{
                            expand: true,
                            cwd: '<%= dirs.buildPath %>/sales',
                            src: ['app/**/*.js', '!*.min.js'],
                            dest: '<%= dirs.buildPath %>/sales'
                        }]
                }
            },
            cssmin: {
                target: {
                    files: [{
                            expand: true,
                            cwd: '<%= dirs.buildPath %>/sales/assets/css',
                            src: ['*.css', '!*.min.css'],
                            dest: '<%= dirs.buildPath %>/sales/assets/css'
                        }]
                }
            },
            connect: {
                server: {
                    options: {
                        hostname: 'localhost',
                        port: 3000,
                        base: '<%= dirs.buildPath %>/',
                        livereload: true
                    }
                }
            },
            watch: {
                options: {
                    spawn: false,
                    livereload: true
                },
                scripts: {
                    files: ['source/**'],
                    tasks: ['clean', 'html2js', 'concat', 'bower_concat', 'copy']
                }
            },
            // grunt-open will open your browser at the project's URL
            open: {
                server: {
                    // Gets the port from the connect configuration
                    path: 'http://localhost:8090/Sales'
                },
                local: {
                    // Gets the port from the connect configuration
                    path: 'http://localhost:<%= connect.server.options.port%>'
    
                }
            }
    
        });
    
        grunt.loadNpmTasks('grunt-contrib-concat');
        grunt.loadNpmTasks('grunt-contrib-watch');
        grunt.loadNpmTasks('grunt-contrib-connect');
        grunt.loadNpmTasks('grunt-open');
        grunt.loadNpmTasks('grunt-bower-concat');
        grunt.loadNpmTasks('grunt-contrib-copy');
        grunt.loadNpmTasks('grunt-contrib-clean');
        grunt.loadNpmTasks('grunt-contrib-uglify');
        grunt.loadNpmTasks('grunt-contrib-cssmin');
        grunt.loadNpmTasks('grunt-ng-annotate');
        grunt.loadNpmTasks('grunt-html2js');
        
        grunt.registerTask('test', ['clean', 'tomcat_deploy', 'nodeunit']);
        grunt.registerTask('default', ['clean', 'html2js', 'concat', 'bower_concat', 'copy', 'open:local', 'connect', 'watch']);
        grunt.registerTask('serve', ['clean', 'html2js', 'concat', 'bower_concat', 'copy', 'open:server', 'watch']);
        grunt.registerTask('prod', ['clean', 'html2js', 'concat', 'bower_concat', 'copy','ngAnnotate','uglify', 'copy:toJavaServer', 'cssmin', 'open:server', 'watch']);
    };
    

    【讨论】:

    • 能否请您进行更改并将其粘贴到此处谢谢
    • 更改后出现以下错误正在加载“bower-concat.js”任务...错误>> ReferenceError:未定义原始警告:未找到任务“bower_concat”。使用 --force 继续。由于警告而中止。
    • @VenkatPrasad 这已经是更正的脚本了
    • @VenkatPrasad 可以发其他脚本吗
    猜你喜欢
    • 1970-01-01
    • 2013-03-11
    • 2018-06-15
    • 2019-05-30
    • 2020-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多