Javascript 我在哪里注册我的JS,以便grunt添加它?

Javascript 我在哪里注册我的JS,以便grunt添加它?,javascript,node.js,gruntjs,bower,yeoman,Javascript,Node.js,Gruntjs,Bower,Yeoman,我使用了一个约曼生成器(html5站点) 我有一个现有的项目,我想转化为grunt/bower工作流 我有一个.js文件,它满足了我的需求,来自旧项目。 将其复制到基于bower/grunt的新项目的开发文件夹中不会导致将其连接到concated到最终的单个mainsite.js 因此,我检查了gruntfile.js并将其添加到这里: concat : { options: { banner: '<%= banner %>',

我使用了一个约曼生成器(html5站点)

我有一个现有的项目,我想转化为grunt/bower工作流

我有一个.js文件,它满足了我的需求,来自旧项目。 将其复制到基于bower/grunt的新项目的开发文件夹中不会导致将其连接到concated到最终的单个mainsite.js

因此,我检查了gruntfile.js并将其添加到这里:

concat : {
        options: {
            banner: '<%= banner %>',
            stripBanners: false
        },
        main : {
            src : [
                'bower_components/jquery/dist/jquery.js',
                'bower_components/jQueryui/ui/jquery-ui.js',
                'bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.js ',
                'bower_components/RWD-FitText.js/jquery.fittext.js',
                'bower_components/BrowserDetection.js/BrowserDetection.js',
                'bower_components/respond/dest/respond.src.js',
                'main-2k15-dribble/JavaScript/Main.js',
                'main-2k15-dribble/JavaScript/mainsite.js',
this added--->      'main-2k15-dribble/JavaScript/jribble.js'
            ],
            dest : 'main-2k15-dribble-pub/js/mainsite.js'
        }
    },
concat:{
选项:{
横幅:'',
彩旗:假
},
主要内容:{
src:[
'bower_components/jquery/dist/jquery.js',
'bower_components/jQueryui/ui/jQueryui.js',
“bower_components/jqueryui touch-punch/jquery.ui.touch-punch.js”,
'bower_components/RWD FitText.js/jquery.FitText.js',
'bower_components/BrowserDetection.js/BrowserDetection.js',
'bower_components/respond/dest/respond.src.js',
'main-2k15-dribble/JavaScript/main.js',
'main-2k15-dribble/JavaScript/mainsite.js',
这增加了-->'main-2k15-dribble/JavaScript/jribble.js'
],
dest:'main-2k15-dribble-pub/js/mainsite.js'
}
},
我特别想知道我需要做什么才能将我现有的javascript添加到由grunt和bower管理的项目中?


一般来说,我从来没有见过一个明确的描述,文件夹是什么意思,工作流是什么,然后添加到脚手架项目中。然而,我觉得一定有一些维基或什么东西在教这个!我不相信开发人员会通过跟踪和错误发现这一点…

我无法猜测您是否这样做,但您需要加载npm,然后注册一个任务来完成这一点,因此您的Gruntfile.js应该如下所示:

'use strict';

module.exports = function (grunt) {

    // Project Configuration
    grunt.initConfig({
        concat: {
            options: {
                banner: '<%= banner %>',
                stripBanners: false
            },
            main: {
                src: [
                    'bower_components/jquery/dist/jquery.js',
                    'bower_components/jQueryui/ui/jquery-ui.js',
                    'bower_components/jqueryui-touch-punch/jquery.ui.touch-punch.js ',
                    'bower_components/RWD-FitText.js/jquery.fittext.js',
                    'bower_components/BrowserDetection.js/BrowserDetection.js',
                    'bower_components/respond/dest/respond.src.js',
                    'main-2k15-dribble/JavaScript/Main.js',
                    'main-2k15-dribble/JavaScript/mainsite.js',
                    'main-2k15-dribble/JavaScript/jribble.js'],
                dest: 'main-2k15-dribble-pub/js/mainsite.js'
            }
        },
    });

    require('load-grunt-tasks')(grunt);

    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.registerTask('concat', ['concat']);
};

愚蠢的问题,但是你运行过grunt任务吗?这个=哪个?Grunt concat是Grunt serve的一部分。如果我更改配置,我会重新运行grunt服务。好的,听起来好像它正在运行concat。可能会检查您的文件是否通过了“jslint”测试。我说不出来,因为我们没有完整的grunt文件,但是如果有一些不好的语法,它可能不会出现。我这里有完整的文件:pastebin.com/zejAdgurcan您是否覆盖了“main-2k15-dribble-pub/js/mainsite.js”?可能是被什么东西锁住了。我单独运行了,但没有用。这是完整的gruntfile文件:在大的封闭卷曲括号后面的分号之后添加您的修改导致了一个frezze:)grunt serve和grunt concat冻结。您没有这个
grunt.loadNpmTasks('grunt-contrib-concat')我编辑了我的,正如我说的,在一个不好的语法中有一条你的评论,添加了
grunt.loadNpmTasks('grunt-contrib-concat')导致冻结/无限循环。也许我把它放错地方了?您的建议是否与
grunt.registerTask('serve'、['clean:css'、'less'、'clean:js'、'concat'、'clean:site'、'assembly'、'replace:dev'、'copy:dev'、'connect:livereload'、'notify:dev'、'watch')重复
grunt concat