问题描述
我有咕噜声的问题。我的 Grunt 版本是:
- grunt-cli v1.4.3
- 咕噜 v1.4.1
运行任何任务时发生错误。
Warning: Task "speak" not found. Use --force to continue.
我运行的每个函数都会发生这种情况(例如 grunt css 或 grunt default function)。我试图取出整个代码并制作一个测试函数并且它起作用了......所以我可以找出全局安装是问题所在。一定是我的 Gruntfile 出错了。
同时我发现有些任务的语法结构不正确。我改变了那个。现在它运行我的默认任务和其他任务而没有错误,首先它看起来一切正常。但是当我测试它时。 SCSS 文件中的更改未显示在已编译的 CSS 文件中...
所以一定还是有问题。所以我添加了新的 Gruntfile 并用 name 替换了我在 Banner 中的名字(所以不要对此感到奇怪)。也许有人知道这个问题......我也不知道它是否真的会在没有额外插件的情况下使用这个 gruntfile 代码制作源地图......但最重要的是它编译了 scss......没有使用 grunt 的全部原因已经消失...
有没有人知道怎么回事
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'],'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','uglify']);
grunt.registerTask('css','cssmin']);
grunt.registerTask('js','uglify');
grunt.registerTask('publish','uglify','htmlmin']);
grunt.registerTask('speak',function() {
console.log('I am running!');
});
};
在 package.json 中安装 grunt 的软件包:
"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"
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)