Grunt-无法缩小js文件
Grunt - not able to minifiy js file
我正在我的应用程序上运行grunt
到jshinting
和minification
,其中jshint
正在工作,但minification
命令根本不工作。得到这样的错误:
D:'grunt>grunt min
Warning: Task "min" not found. Use --force to continue.
Aborted due to warnings.
这是我的配置文件:
module.exports = function(grunt){
// Project configuration.
grunt.initConfig({
jshint: {
options: {
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
},
myFiles: ['js/**/*.js']
},
min:{
dest : {
src:'js/app.js',
dest:'js/app.min.js'
}
},
});
// Each plugin must be loaded following this pattern
grunt.loadNpmTasks('grunt-contrib-jshint');
}
在这个项目中,我安装的模块是:
grunt, grunt-contrib-jshint, jshint
-我不知道我做错了什么。。请任何人帮我解决这个问题。
提前感谢!
要缩小您需要的文件,例如uglify。
使用以下命令安装:
npm install grunt-contrib-uglify --save-dev
然后,将其添加到Gruntfile 中
grunt.loadNpmTasks('grunt-contrib-uglify');
最后,您必须更改Gruntfile的代码:
grunt.initConfig({
jshint: {
options: {
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
}
},
myFiles: ['js/**/*.js']
},
uglify:{
dest : {
files: {
'js/app.min.js': ['js/app.js']
}
}
},
});
谨致问候。
您需要安装类似的迷你任务
grunt-contrib-uglify
以便缩小文件。
更多关于Grunt contrib丑陋
使用uglify 的Grunt文件样本
相关文章:
- JS文件的路径正在消失
- 我的外部js文件无法加载
- 在不破坏未定义函数的情况下,对多个视图使用单个js文件
- 动态加载和卸载js文件
- 如何将变量传递到另一个js文件
- 如何将所有JS文件连接到一个文件夹中
- 从Chrome扩展名中的popup.html文件在background.js文件中运行一个函数
- 如何使用php文件中的GET来获取我在.js文件中声明的变量
- 如何将模板中的标记脚本移动到.js文件中
- 什么's是连接供应商js文件的最佳方式
- 如何在定义js文件后为外部javascript文件设置变量
- 如何在JS文件中获取资源(.resx)字符串
- 将*.js文件的内容放入Object中
- 如何从onclick函数设置全局变量并将其传递给另一个JS文件
- 导致内容安全策略(CSP)冲突错误的本地jquery.js文件
- 如何使用Gmail运行.js文件
- 如何定义一个模块并使用它来分离js文件
- Angular JS文件上传到托管服务器
- 如何引用HTML中节点模块中的js文件
- 如何将JS文件从其他文件夹链接到页面