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"
}
}