首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >咕噜发球不管用。因为injector.sass失踪了?

咕噜发球不管用。因为injector.sass失踪了?
EN

Stack Overflow用户
提问于 2020-02-20 13:45:13
回答 1查看 106关注 0票数 0

在我的终端中,我得到了以下错误:运行"injector:sass“(注入器)任务来验证属性injector.sass在config...ERROR中的存在

无法处理任务。警告:缺少必需的配置属性"injector.sass“。继续使用武力。

由于警告而中止。

另外,bundle/vendor.js脚本没有加载到我的普通应用程序中。

我的抱怨文件是:

代码语言:javascript
复制
/* global module, require, process */

(function(){
'use strict';
module.exports = function(grunt) {

    var localConfig;
    try {
        localConfig = require('./server/configuration/local_env.express');
    } catch (e) {
        localConfig = {};
    }

    require('jit-grunt')(grunt, {
        express: 'grunt-express-server',
        ngtemplates: 'grunt-angular-templates',
        buildcontrol: 'grunt-build-control'
    });

    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-contrib-qunit');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-browserify');
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-injector');
    grunt.loadNpmTasks('grunt-angular-templates');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-build-control');
    grunt.loadNpmTasks('grunt-ng-annotate');


    grunt.initConfig({

        pkg: grunt.file.readJSON('package.json'),
        application: {
            name: 'UPBIS B2B Social Platform',
            client: require('./bower.json').appPath || 'client',
            js: 'client/app/**/*.js',
            dist: 'dist'
        },
        express: {
            options: {
                port: process.env.PORT || 9000
            },
            dev: {
                options: {
                    script: 'server/app.js',
                    debug: true
                }
            },
            prod: {
                options: {
                    script: 'dist/server/app.js'
                }
            }
        },
        open: {
            server: {
                url: 'http://localhost:<%= express.options.port %>'
            }
        },
        qunit: {
            all: {
                options: {
                    urls: ['http://localhost:9002/test.html']
                }
            }
        },
        connect: {
            server: {
                options: {
                    port: 9002,
                    base: './client'
                }
            }
        },
        uglify: {
            options: {

                banner: '/*! <%= application.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
                mangle: false
            },
            dist: {
                files: {
                    'dist/public/bundles/vendor.js': ['dist/public/bundles/vendor.js'],
                    'dist/public/bundles/code.js': ['dist/public/bundles/code.js']
                }
            }
        },
        browserify: {
            dist: {
                files: {
                    'dist/public/bundles/vendor.js': ['client/app/vendor.browserify.js'],
                    'dist/public/bundles/code.js': ['client/app/code.browserify.js', '<%= ngtemplates.app.dest %>']
                },

            }
        },
        jshint: {
            options: {
                globals: {
                    jQuery: true,
                    console: true,
                    module: true,
                    document: true
                },
                jshintrc: '<%= application.client %>/.jshintrc',
                reporter: require('jshint-stylish')
            },
            server: {
                options: {
                    jshintrc: 'server/.jshintrc'
                },
                src: [
                    'server/**/*.js',
                    '!server/**/*.spec.js'
                ]
            },
            serverTest: {
                options: {
                    jshintrc: 'server/.jshintrc-spec'
                },
                src: ['server/**/*.spec.js']
            },
            all: [
                '<%= application.client %>/{app,components}/**/*.js',
                '!<%= application.client %>/{app,components}/**/*.spec.js',
                '!<%= application.client %>/{app,components}/**/*.mock.js'
            ],
            test: {
                src: [
                    '<%= application.client %>/{app,components}/**/*.spec.js',
                    '<%= application.client %>/{app,components}/**/*.mock.js'
                ]
            }
        },
        sass: { // Task
            dist: { // Target
                options: { // Target options
                    style: 'compressed',
                    compass: true
                },
                files: { // Dictionary of files
                    'dist/public/style.min.css': '<%= application.client %>/app/sass/style.scss' // 'destination': 'source'
                }
            }
        },
        watch: {
            jshint: {
                files: ['<%= application.js %>'],
                tasks: ['jshint']
            },
            browserify: {
                files: ['<%= application.js %>'],
                tasks: ['browserify']
            },

            inject_css: {
                files: ['dist/style.css'],
                tasks: ['injector:css']
            },
            inject_bundles: {
                files: ['dist/public/bundles/vendor.js', 'dist/public/bundles/code.js'],
                tasks: ['injector:scripts']
            },

        },
        ngtemplates: {
            options: {
                module: 'upbisApp',
                htmlmin: {
                    collapseBooleanAttributes: true,
                    collapseWhitespace: true,
                    removeAttributeQuotes: true,
                    removeEmptyAttributes: true,
                    removeRedundantAttributes: true,
                    removeScriptTypeAttributes: true,
                    removeStyleLinkTypeAttributes: true
                },
            },
            app: {
                cwd: '<%= application.client %>',
                src: ['app/**/*.html'],
                dest: '.tmp/templates.js'
            },
        },
        copy: {
            dist: {
                files: [{
                        expand: true,
                        dot: true,
                        cwd: '<%= application.client %>',
                        dest: '<%= application.dist %>/public',
                        src: [
                            '*.{ico,png,txt}',
                            '.htaccess',
                            'assets/**/*',
                            'nginx/**/*',
                            'index.html'
                        ]
                    }, {
                        expand: true,
                        cwd: '.tmp/images',
                        dest: '<%= application.dist %>/public/assets/images',
                        src: ['generated/*']
                    },


                    {
                        expand: true,
                        dot: true,
                        cwd: '<%= application.client %>/bower_components/material-design-iconic-font/dist',
                        dest: '<%= application.dist %>/public',
                        src: [
                            'fonts/*',
                        ]
                    },

                    {
                        expand: true,
                        dest: '<%= application.dist %>',
                        src: [
                            'package.json',
                            'server/**/*'
                        ]
                    }
                ]
            },
        },
        env: {
            test: {
                NODE_ENV: 'test'
            },
            prod: {
                NODE_ENV: 'production'
            },
            all: localConfig
        },
        injector: {
            options: {
                template: '<%= application.dist %>/public/index.html'
            },
            scripts: {
                options: {
                    transform: function(filePath) {
                        filePath = filePath.replace('/dist/public/', '');
                        return '<script src="' + filePath + '"></script>';
                    },
                    starttag: '<!-- injector:js -->',
                    endtag: '<!-- endinjector -->'
                },
                files: {
                    '<%= application.dist %>/public/index.html': ['<%= application.dist %>/public/bundles/vendor.js', '<%= application.dist %>/public/bundles/code.js', ]
                }
            },


            css: {
                options: {
                    transform: function(filePath) {
                        filePath = filePath.replace('/dist/public/', '');
                        return '<link rel="stylesheet" href="' + filePath + '">';
                    },
                    starttag: '<!-- injector:css -->',
                    endtag: '<!-- endinjector -->'
                },
                files: {
                    '<%= application.dist %>/public/index.html': [
                        '<%= application.dist %>/public/style.min.css'
                    ]
                }
            }
        },

        ngAnnotate: {
            options: {
                singleQuotes: true,
            },

            app: {
                files: [
                    {
                        src: ['./client/app/profile/about/about.ngcontroller.js'],
                        expand: true,
                        ext: '.annotated.js',
                        extDot: 'last',

                    }
                ]
            }

        },

        clean: {
            dist: {
                files: [{
                    dot: true,
                    src: [
                        '.tmp',
                        '<%= application.dist %>/*',
                        '!<%= application.dist %>/.git*',
                        '!<%= application.dist %>/.openshift',
                        '!<%= application.dist %>/Procfile'
                    ]
                }]
            },
            server: '.tmp'
        },
        buildcontrol: {
            options: {
                dir: 'dist',
                commit: true,
                push: true,
                connectCommits: false,
                message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
            },
            heroku: {
                options: {
                    remote: 'git@heroku.com:aqueous-stream-9919.git',
                    branch: 'dist',
                    remoteBranch: 'master'
                }
            }

        }

    });


    grunt.registerTask('express-keepalive', 'Keep grunt running', function() {
        this.async();
    });

    grunt.registerTask('serve', function(target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'env:all', 'env:prod', 'express:prod', 'buildcontrol']);
        }

        if (target === 'debug') {
            return grunt.task.run([
                'clean:server',
                'env:all',
                'injector:sass',
                'concurrent:server',
                'injector',
                'wiredep',
                'autoprefixer',
                'concurrent:debug'
            ]);
        }

        grunt.task.run([
            'clean:server',
            'env:all',
            'injector:sass',
            'concurrent:server',
            'injector',
            'wiredep',
            'autoprefixer',
            'express:dev',
            'wait',
            'open',
            'watch'
        ]);
    });

    grunt.registerTask('build', [
        'clean:dist',
        'connect',
        'qunit',
        'jshint',
        'ngtemplates',
        'browserify',
        'sass',
        'uglify',
        'copy:dist',
        'injector'
    ]);



};

})();

我错过了什么,我怎么解决这个问题?

EN

回答 1

Stack Overflow用户

发布于 2020-03-04 19:27:30

咕噜喷射器是一个多任务的系统。开始,调用injector:sass会导致injector.sass开始查找配置对象。您的配置没有键sass作为injector的子级,这解释了失败的原因。

解决这一问题的两种方法:

选项A:将injector:sass替换为injector:css。这是我的猜测,但也许这就是您的意思,您的注入器配置确实有一个css目标,但没有一个sass目标。

选项B:在注入器配置中添加一个sass目标,类似于以下内容:

代码语言:javascript
复制
const config = {
    injector: {
        sass: {
            // configuration goes here to support the task `injector.sass`
        }
    }
}

如果要查找有关原因的更多信息,Grunt.js文档中的本节将解释配置目标与多任务之间的关系:https://gruntjs.com/configuring-tasks#task-configuration-and-targets

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60321398

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档