grunt-bowercopy产生警告 - 没有复制文件

时间:2016-10-09 13:46:59

标签: npm gruntjs bower

我已将Grunt设置为使用监视任务编译罗盘,现在我想从 bower_components /...复制有用的文件 - 例如bower_components / jquery / jquery.min.js,因为bower会在上传到服务器时产生大量不必要的文件,我想摆脱这些文件。

CMD产生警告并停止过程;

    Reading C:\Users\sjiamnocna\Documents\NetBeansProjects\PM_new\node_modules\grunt-bowercopy\package.json...OK
Parsing C:\Users\sjiamnocna\Documents\NetBeansProjects\PM_new\node_modules\grunt-bowercopy\package.json...OK
Reading bower.json...OK
Parsing bower.json...OK
Loading "bowercopy.js" tasks...OK
+ bowercopy
Loading "gruntfile.js" tasks...OK
+ default, dog

No tasks specified, running default tasks.
Running tasks: default

Running "default" task

Running "bowercopy" task

Running "bowercopy:copythat" (bowercopy) task
Verifying property bowercopy.copythat exists in config...OK
File: [no files]
Options: srcPrefix="bower_components", destPrefix="files", ignore=[], report, runBower=false, clean=false, copyOptions={}
Using srcPrefix: bower_components
Using destPrefix: files
Warning: Nothing was copied for the "copythat" target Use --force to continue.

我的gruntfile:

    module.exports = function (grunt) {
    grunt.initConfig({
        watch: {
            scss: {
                files: ['files/style/sass/*.scss'],
                tasks: ['compass']
            }
        },
        compass: {
            dist: {
                options: {
                    sassDir: 'files/style/sass',
                    cssDir: 'files/style',
                    environment: 'development'
                }
            }
        },
        bowercopy: {
            copythat: {
                options: {
                    runBower: false,
                    srcPrefix: 'bower_components',
                    destPrefix: 'files'
                },
                script: {
                    'jquery/dist/jquery.min.js': 'script/lib/jquery.min.js',
                    'jquery-ui/jquery-ui.min.js': 'script/lib/jquery-ui.min.js',
                    'masonry/dist/masonry.pkgd.min.js': 'script/lib/masonry.pkgd.min.js',
                    'sweetalert/dist/sweetalert.min.js': 'script/lib/sweetalert.min.js'
                }
            }
        }
    });
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-compass');
    grunt.loadNpmTasks('grunt-bowercopy');

    grunt.registerTask('default', ['bowercopy']);
    grunt.registerTask('dog', ['watch']);

};

谁能告诉我什么错了?或者,还有其他方法可以用grunt(自动:))吗?

1 个答案:

答案 0 :(得分:0)

感谢@cartant发表评论,这是我犯过的错误之一 - 使用的不是“文件”

我已经改变了资源和目标的位置

错:

'source':'target'

改进:

'target':'source'

作品!