获取错误消息“否”concat“目标找到“运行grunt-usemin时 [英] Getting Error message "No "concat" targets found" when running grunt-usemin

查看:187
本文介绍了获取错误消息“否”concat“目标找到“运行grunt-usemin时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  module.exports = function(grunt){

//项目配置。
grunt.initConfig({
pkg:grunt.file.readJSON('package.json'),
uglify:{
options:{
banner:'/ *!<%= pkg.name%><%= grunt.template.today(yyyy-mm-dd)%> * / \ n'
},
build :{
src:'src / ** / *。js',
dest:'dist /<%= pkg.name%> .min.js'
}
$ b watch:{
js:{
files:['src / ** / *。js'],
options:{
livereload: '<%= connect.options.livereload%>'
}
},
livereload:{
options:{
livereload:'<%= connect.options.livereload%>'
},
文件:[
'src / ** / *。html',
'src / ** / *。css ',
'src / assets / images / {,* /} *。{png,jpg,jpeg,gif,webp,svg}'
]
}
},
connect: {
options:{
port:9000,
livereload:35729,
hostname:'localhost'
},
livereload:{
选项:{
open:true,
// base:[
//'.tmp',
//''
//]
中间件:function(connect){
return [
connect.static('。tmp'),
connect()。use(
/ bower_components',
connect.static('./ bower_components')
),
connect()。 se(
/ app / styles',
connect.static('./ app / styles')
),
connect.static('src')
];
}
}
}
},
复制:{
app:{
cwd:'src',//设置工作文件夹/ root复制
src:'** / *。html',//复制所有文件和子文件夹
dest:'dist /',//目标文件夹
展开:true
$,
assets:{
cwd:'src',//设置工作文件夹/ root复制
src:'assets / *',//复制所有文件和子文件夹
dest:'dist /',//目标文件夹
展开:true
}
},
useminPrepare:{
options:{
dest:'dist'
},
html:'src / index.html'
},

usemin:{
html:['dist /index.html']
}

});

//载入提供uglify任务的插件。
// grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-usemin');

//默认任务。
grunt.registerTask('default',['useminPrepare','copy','concat','uglify','usemin']);
grunt.registerTask('serve',function(target){
grunt.task.run([
'connect:livereload',$ b $'watch'
] );
});

};

当我运行grunt获取错误信息为Noconcatfound found。
我一直在尝试2个小时来解决这个问题,但没有结果帮助我解决问题。

>太晚了,但以防万一它对其他人有用:我相信useminprepare会自动生成一个concat配置并将其提供给grunt task runner,所以上面的响应不太准确,我会说。



我会尝试检查src / index.html中的构建块,并检查路径是否正确指向useminPrepare将要连接的资源。我现在正在努力解决像这样的问题:S



这里引用: https://github.com/yeoman/grunt-usemin


My grunt file is shown below:

module.exports = function(grunt) {

    // Project configuration.
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        uglify: {
            options: {
                banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
            },
            build: {
                src: 'src/**/*.js',
                dest: 'dist/<%= pkg.name %>.min.js'
            }
        },
        watch: {
            js: {
                files: ['src/**/*.js'],
                options: {
                    livereload: '<%= connect.options.livereload %>'
                }
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files: [
                    'src/**/*.html',
                    'src/**/*.css',
                    'src/assets/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },
        connect: {
            options: {
                port: 9000,
                livereload: 35729,
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    open: true,
                    // base: [
                    //     '.tmp',
                    //     ''
                    // ]
                    middleware: function(connect) {
                        return [
                            connect.static('.tmp'),
                            connect().use(
                                '/bower_components',
                                connect.static('./bower_components')
                            ),
                            connect().use(
                                '/app/styles',
                                connect.static('./app/styles')
                            ),
                            connect.static('src')
                        ];
                    }
                }
            }
        },
        copy: {
            app: {
                cwd: 'src', // set working folder / root to copy
                src: '**/*.html', // copy all files and subfolders
                dest: 'dist/', // destination folder
                expand: true
            },
            assets: {
                cwd: 'src', // set working folder / root to copy
                src: 'assets/*', // copy all files and subfolders
                dest: 'dist/', // destination folder
                expand: true
            }
        },
        useminPrepare: {
            options: {
                dest: 'dist'
            },
            html: 'src/index.html'
        },

        usemin: {
            html: ['dist/index.html']
        }

    });

    // Load the plugin that provides the "uglify" task.
    // grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-usemin');

    // Default task(s).
    grunt.registerTask('default', ['useminPrepare', 'copy', 'concat', 'uglify', 'usemin']);
    grunt.registerTask('serve', function(target) {
        grunt.task.run([
            'connect:livereload',
            'watch'
        ]);
    });

};

when i run grunt getting error message as "No "concat" targets found". I have been trying for 2 hours to solve this problem but no result pls help me to get the solution.

解决方案

Way too late, but just in case it is useful for somebody else: I believe useminprepare will auto-generate a concat configuration and feed it to the grunt task runner, so above responses are not quite accurate I would say.

I would try reviewing the build blocks in src/index.html and check that the paths point properly to the resources that useminPrepare will concatenate. I'm struggling now with a problem like this :S

Reference here: https://github.com/yeoman/grunt-usemin

这篇关于获取错误消息“否”concat“目标找到“运行grunt-usemin时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆