Build 为什么自定义的yeoman phpwebapp中的构建块会导致grunt构建失败?

Build 为什么自定义的yeoman phpwebapp中的构建块会导致grunt构建失败?,build,yeoman,gruntjs,Build,Yeoman,Gruntjs,我用的是新的约曼发电机。我对我的Gruntfile和index做了一些调整,这样我就可以在CMS中使用它了 索引中的块被认为是丑陋(连接和缩小)脚本,导致grunt build失败 grunt.initConfig中的丑陋任务成功,只有块失败 错误 导致生成失败的块的示例。 我的Gruntfile “严格使用”; var lrnippet=require('grunt-contrib-livereload/lib/utils')。livereloadSnippet; var mountFol

我用的是新的约曼发电机。我对我的
Gruntfile
index
做了一些调整,这样我就可以在CMS中使用它了

索引中的块被认为是丑陋(连接和缩小)脚本,导致
grunt build
失败

grunt.initConfig
中的丑陋任务成功,只有块失败

错误 导致生成失败的块的示例。

我的Gruntfile
“严格使用”;
var lrnippet=require('grunt-contrib-livereload/lib/utils')。livereloadSnippet;
var mountFolder=函数(连接,目录){
返回connect.static(require('path').resolve(dir));
};
module.exports=函数(grunt){
//加载所有grunt任务
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
//可配置路径
var yeomanConfig={
应用程序:“应用程序”,
dist:“dist”
};
//静态变量
变量主题名称='cb',
theme\u path='\u themes/'+theme\u name;//cssmin和uglify设置不接受变量
grunt.initConfig({
约曼:约曼图,
观察:{
咖啡:{
文件:['/'+主题路径+'/coffee/*.coffee'],
任务:['coffee:dist']
},
咖啡测试:{
文件:['test/spec/*.coffee'],
任务:[“咖啡:测试”]
},
指南针:{
文件:['/'+theme_path+'/scss/*.{scss,sass}'],
任务:[“指南针”]
},
利弗雷罗德:{
档案:[
'/'+theme_path+'/{layouts,partials,templates}/*.html',
“/*.php”,
{.tmp,}/'+theme_path+'/css/*.css',
{.tmp,}/'+theme_path+'/js/*.js',
“/”+主题路径+”/img/*。{png,jpg,jpeg,webp}”
],
任务:['livereload']
}
},
连接:{
选项:{
港口:9000,
//将此更改为“0.0.0.0”以从外部访问服务器
主机名:“localhost”
},
利弗雷罗德:{
选项:{
中间件:功能(连接){
返回[
小片段,
mountFolder(连接“.tmp”),
安装文件夹(连接“应用程序”)
];
}
}
},
测试:{
选项:{
中间件:功能(连接){
返回[
mountFolder(连接“.tmp”),
安装文件夹(连接“测试”)
];
}
}
},
地区:{
选项:{
中间件:功能(连接){
返回[
mountFolder(连接“dist”)
];
}
}
}
},
开放式:{
服务器:{
网址:'http://localhost.curtisblackwell.com'
}
},
清洁:{
地区:['.tmp','/*'],
服务器:'.tmp',
build:“/scripts/remove me on build.js”
},
jshint:{
选项:{
jshintrc:“.jshintrc”
},
全部:[
“Gruntfile.js”,
“/”+主题路径+”/js/*.js',
“test/spec/*.js”
]
},
摩卡咖啡:{
全部:{
选项:{
run:是的,
网址:['http://localhost:/index.html']
}
}
},
咖啡:{
地区:{
档案:[{
是的,
cwd:'/'+主题路径+'/js',
src:“*.咖啡”,
dest:'.tmp/'+主题路径+'/js',
分机:'.js'
}]
},
测试:{
档案:[{
是的,
cwd:“.tmp/spec”,
src:“*.咖啡”,
目的:“测试/规格”
}]
}
},
指南针:{
选项:{
sassDir:“/”+主题路径+“/scss”,
cssDir:'.tmp/'+主题路径+'/css',,
imagesDir:'/'+主题路径+'/img',
javascriptsDir:'/'+主题路径+'/js',
fontsDir:“/”+主题路径+“/css/fonts”,
导入路径:“应用程序/组件”,
相对论:对
},
地区:{},
服务器:{
选项:{
debugInfo:true
}
}
},
//未使用,因为丑陋的任务不起作用,
//但如果需要,仍然可用
/*康卡特:{
地区:{}
},*/
丑陋的:{
地区:{
档案:{
“/_themes/cb/js/cb.js”:[
“/”+主题路径+”/js/*.js”
],
}
}
},
使用准备:{
html:'/'+theme_path+'/{布局、部分、模板}/**,
选项:{
目标:“”
}
},
usemin:{
html:['/'+主题路径+'/{布局、部分、模板}/**'],
css:['/'+主题路径+'/css/*.css'],
选项:{
目录:['']
}
},
imagemin:{
地区:{
档案:[{
是的,
cwd:“”,
src:'{assets/img/**,'+theme\u p
Running "uglify:dist" (uglify) task
File "dist/_themes/cb/js/cb.js" created.
Uncompressed size: 48 bytes.
Compressed size: 31 bytes gzipped (16 bytes minified).

Running "uglify:dist/scripts/plugins.js" (uglify) task
Warning: Uglification failed. Use --force to continue.
<!-- build:js scripts/plugins.js -->
<script src="components/sass-bootstrap/js/bootstrap-affix.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-alert.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-dropdown.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-tooltip.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-modal.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-transition.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-button.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-popover.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-typeahead.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-carousel.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-scrollspy.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-collapse.js"></script>
<script src="components/sass-bootstrap/js/bootstrap-tab.js"></script>
<!-- endbuild -->
'use strict';
var lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet;
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

module.exports = function (grunt) {
    // load all grunt tasks
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

    // configurable paths
    var yeomanConfig = {
        app: 'app',
        dist: 'dist'
    };

    // Statamic Vars
    var theme_name = 'cb',
        theme_path = '_themes/' + theme_name; // cssmin and uglify settings don't accept vars

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            coffee: {
                files: ['<%= yeoman.app %>/' + theme_path + '/coffee/*.coffee'],
                tasks: ['coffee:dist']
            },
            coffeeTest: {
                files: ['test/spec/*.coffee'],
                tasks: ['coffee:test']
            },
            compass: {
                files: ['<%= yeoman.app %>/' + theme_path + '/scss/*.{scss,sass}'],
                tasks: ['compass']
            },
            livereload: {
                files: [
                    '<%= yeoman.app %>/' + theme_path + '/{layouts,partials,templates}/*.html',
                    '<%= yeoman.app %>/*.php',
                    '{.tmp,<%= yeoman.app %>}/' + theme_path + '/css/*.css',
                    '{.tmp,<%= yeoman.app %>}/' + theme_path + '/js/*.js',
                    '<%= yeoman.app %>/' + theme_path + '/img/*.{png,jpg,jpeg,webp}'
                ],
                tasks: ['livereload']
            }
        },
        connect: {
            options: {
                port: 9000,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'app')
                        ];
                    }
                }
            },
            test: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test')
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, 'dist')
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost.curtisblackwell.com'
            }
        },
        clean: {
            dist: ['.tmp', '<%= yeoman.dist %>/*'],
            server: '.tmp',
            build: '<%= yeoman.dist %>/scripts/remove-me-on-build.js'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc'
            },
            all: [
                'Gruntfile.js',
                '<%= yeoman.app %>/' + theme_path + '/js/*.js',
                'test/spec/*.js'
            ]
        },
        mocha: {
            all: {
                options: {
                    run: true,
                    urls: ['http://localhost:<%= connect.options.port %>/index.html']
                }
            }
        },
        coffee: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/' + theme_path + '/js',
                    src: '*.coffee',
                    dest: '.tmp/' + theme_path + '/js',
                    ext: '.js'
                }]
            },
            test: {
                files: [{
                    expand: true,
                    cwd: '.tmp/spec',
                    src: '*.coffee',
                    dest: 'test/spec'
                }]
            }
        },
        compass: {
            options: {
                sassDir: '<%= yeoman.app %>/' + theme_path + '/scss',
                cssDir: '.tmp/' + theme_path + '/css',
                imagesDir: '<%= yeoman.app %>/' + theme_path + '/img',
                javascriptsDir: '<%= yeoman.app %>/' + theme_path + '/js',
                fontsDir: '<%= yeoman.app %>/' + theme_path + '/css/fonts',
                importPath: 'app/components',
                relativeAssets: true
            },
            dist: {},
            server: {
                options: {
                    debugInfo: true
                }
            }
        },
        // not used since Uglify task does concat,
        // but still available if needed
        /*concat: {
            dist: {}
        },*/

        uglify: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/_themes/cb/js/cb.js': [
                        '<%= yeoman.app %>/' + theme_path + '/js/*.js'
                    ],
                }
            }
        },
        useminPrepare: {
            html: '<%= yeoman.app %>/' + theme_path + '/{layouts,partials,templates}/**',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/' + theme_path + '/{layouts,partials,templates}/**'],
            css: ['<%= yeoman.dist %>/' + theme_path + '/css/*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: '{assets/img/**,' + theme_path + '/img/*.{png,jpg,jpeg}}',
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        cssmin: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/_themes/cb/css/cb.css': [
                        '.tmp/' + theme_path + '/css/*.css',
                        '<%= yeoman.app %>/' + theme_path + '/css/*.css'
                    ]
                }
            }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: '/' + theme_path + '/templates/' + '*.html',
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,txt,php}',
                        '.htaccess',
                        '_{add-ons,app,cache,config,content,cp,logs}/**'
                    ]
                }]
            }
        },
        bower: {
            all: {
                rjsConfig: '<%= yeoman.app %>/' + theme_path + '/js/' + theme_name + '.js'
            }
        }
    });

    grunt.renameTask('regarde', 'watch');

    grunt.registerTask('server', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'coffee:dist',
            'compass:server',
            'livereload-start',
            'connect:livereload',
            'open',
            'watch'
        ]);
    });

    grunt.registerTask('test', [
        'clean:server',
        'coffee',
        'compass',
        'connect:test',
        'mocha'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'coffee',
        'compass:dist',
        'useminPrepare',
        'imagemin',
        'cssmin',
        'htmlmin',
        // 'concat',
        'uglify',
        'copy',
        'usemin',
        'clean:build'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);
};
    uglify: {
        dist: {
            files: [{
                expand: true,
                cwd: '<%= yeoman.dist %>/scripts',
                src: ['**/*.js'],
                dest: '<%= yeoman.dist %>/scripts'
            }]
        }
    },