json 这个Gruntfile.js将清理你的dist文件夹,根据html中指定的配置连接和缩小所有js,css资产,放置修订,缩小
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json 这个Gruntfile.js将清理你的dist文件夹,根据html中指定的配置连接和缩小所有js,css资产,放置修订,缩小相关的知识,希望对你有一定的参考价值。
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
clean: ['dist'],
copy: {
generated: {
src: 'src/index.html',
dest: 'dist/index.html'
}
},
filerev: {
options: {
encoding: 'utf8',
algorithm: 'md5',
length: 20
},
source: {
files: [{
src: [
'dist/js/*.js',
'dist/css/*.css'
]
}]
}
},
useminPrepare: {
html: 'src/index.html',
options: {
dest: 'dist'
}
},
usemin: {
html: 'dist/index.html',
options: {
assetsDirs: ['dist', 'dist/css', 'dist/js', 'css', 'js']
}
},
htmlmin: {
dist: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: {
'dist/index.html': 'dist/index.html'
}
}
}
});
grunt.registerTask('default', [
'clean',
'copy:generated',
'useminPrepare',
'concat',
'uglify',
'cssmin',
'filerev',
'usemin',
'htmlmin'
]);
};
{
"name": "25-grunt-purifycss",
"version": "0.0.1",
"description": "Grunt plugin remove unused css",
"main": "Gruntfile.js",
"repository": {
"type": "git",
"url": "git://github.com/kanakiyajay/grunt-tasks.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jay Kanakiya",
"license": "ISC",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "^0.12.3",
"grunt-contrib-htmlmin": "^0.4.0",
"grunt-contrib-uglify": "^0.9.1",
"grunt-filerev": "^2.3.1",
"grunt-purifycss": "^0.1.0",
"grunt-usemin": "^3.0.0",
"load-grunt-tasks": "^3.1.0"
}
}
以上是关于json 这个Gruntfile.js将清理你的dist文件夹,根据html中指定的配置连接和缩小所有js,css资产,放置修订,缩小的主要内容,如果未能解决你的问题,请参考以下文章
Gruntfile.js
grunt 出现一个奇怪的错误:Object Gruntfile.js 没有“扁平化”方法
grunt使用watch和livereload的Gruntfile.js的配置
Gruntfile.js 中的 JSLint 错误
grunt 合并压缩js和css文件
Gruntfile.js模板