0

I have a problem with grunt. My Grunt version is:

  • grunt-cli v1.4.3
  • grunt v1.4.1

An Error occurs as I run any task.

Warning: Task "speak" not found. Use --force to continue.  

This occurs with every function I run (for example grunt css or grunt default function) . I tried to take out whole code and make a test function and it worked... So I can sort out that the global installation is the problem. It must be my Gruntfile that is wrong.

Meanwhile I found out that some tasks were not in the right syntax structure. I changed that. Now it run my default task and other tasks without errors and firstly it looked like all runs fine. But as I tested it. The Changes in SCSS file doesn't show up in the compiled CSS File...

So something must be still wrong. So I added the new Gruntfile and replaced my name in Banner with name (so don't wonder about that). Maybe somebody know this issue... I also not know if it really would make the sourcemaps with this gruntfile code without additional plugins... But most important is that it compiles the scss ... without the whole reason of using grunt is gone...

Does anybody have an idea whats wrong

module.exports = function(grunt) {
    grunt.initConfig({
        package: grunt.file.readJSON('package.json'),
        
        concat: {
            js: {
                src: 'scripts/js/**/_*.js',
                dest:'scripts/js/app.js'
            },
            css: {
                src: 'scripts/css/**/_*.css',
                dest: 'scripts/css/app.css'
            },
            options: {
                stripBanners: true,
                banner: '//<%= package.name %> - Minified main Javascript from *Name* - <%= grunt.template.today("yyyy-mm-dd") %>'
            }
        },
        uglify: {
            options: {
                banner: '//<%= package.name %> - Minified main Javascript from *Name* - <%= grunt.template.today("yyyy-mm-dd") %>',

                mangle: {
                    reserved: 'jQuery'
                },
                compress: {
                    global_defs: {
                        "DEBUG": false
                    },
                },
                dead_code: false,
                unused: false,
                drop_console: true
            },
            build: {
                src: 'scripts/js/app.js',
                dest: 'build/scripts/js/app.min.js'
            }
        },
        cssmin: {
            options: {
                specialComments: 0,
                mergeIntoShorthands: false,
                roundingPrecision: -1
            },
            target: {
                files: { 
                    'build/scripts/css/app.css': 'scripts/css/app.css'
                }
            }
        },
        sass: {
            build: {
                options: {
                    style: 'expanded',
                    debugInfo: true,
                    sourcemap: true
                    
                },
                files: [{
                    expand: true,
                    cwd: 'scripts/css/',
                    src: ['scripts/scss/**/_*.scss'],
                    dest: 'scripts/css/',
                    ext: '.css'
                }]
            }   
        },
        watch: {
            js: {
                files: ['scripts/js/_*.js'],
                tasks: ['concat', 'uglify']
            },
            css: {
                files: ['scripts/scss/_*.scss'],
                tasks: ['concat', 'sass', 'cssmin']
            },
            php: {
                files: ['*.html'],
                tasks: ['htmlmin']
            }
        },
        htmlmin: {
            options: {
                collapseWhitespace: true
            },
            target: {
                files: {
                    src: '*.html',
                    dest: 'build/index.html'
                }
            }
        }
    });

    //Load Plugins of Grunt
    grunt.loadNpmTasks('grunt-contrib-sass');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-htmlmin');
    grunt.loadNpmTasks('grunt-contrib-cssmin');


    //Grunt Tasks 
    grunt.registerTask('default', ['sass', 'concat', 'cssmin', 'uglify']);
    grunt.registerTask('all', ['sass', 'concat', 'cssmin','uglify']);
    grunt.registerTask('css', ['sass', 'concat', 'cssmin']);
    grunt.registerTask('js', 'uglify');
    grunt.registerTask('publish', ['sass', 'concat', 'cssmin', 'uglify', 'htmlmin']);

    grunt.registerTask('speak', function() {
        console.log('I am running!');
    });
};

Packages installes for grunt in package.json:

"devDependencies": {
        "debug": "^4.3.1",
        "grunt": "^1.4.1",
        "grunt-cli": "^1.4.3",
        "grunt-contrib-concat": "^1.0.1",
        "grunt-contrib-copy": "^1.0.0",
        "grunt-contrib-sass": "^2.0.0",
        "grunt-contrib-uglify": "^5.0.1",
        "grunt-contrib-watch": "^1.1.0",
        "webpack": "^5.40.0",
        "webpack-cli": "^4.7.2"
    }
}
RobC
  • 22,977
  • 20
  • 73
  • 80
Lukas
  • 11
  • 5
  • It seems like the task error just occure if i have the section sass. So maybe the problem is in this area. But even if i leave it out he just run the task and not do his job. He leaves empty files or don't uglify at all... So even if this problem might be there. Other problems also existing in the other area. – Lukas Jul 06 '21 at 20:55
  • It seems like i solved a few errors as i changed the tasks a bit. But one thing is still weird... It now run the default task without errors but it compile not a single file... I would update the gruntfile and place the new one in it and describe a bit the new problem... – Lukas Jul 08 '21 at 20:39

0 Answers0