我正在尝试将HTML文件从ROOT文件夹复制到DIST文件夹,并且HTML将被缩小。到目前为止,我已经实现了这一目标。
现在,当HTML文件被复制到DIST文件夹时,我想在所有包含的CSS和SCRIPTS中更改INCLUDE路径。
有可能吗?我在科技论坛上经历了很多搜索,但在任何地方都找不到。
以下是示例代码:
'use strict';
/**
* Grunt Module
*/
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sass: {
dist: {
options: {
style: 'expanded',
compass: true,
sourcemap: false
},
files: {
'dist/css/<%= pkg.name %>.styles.css': ['sass/**/*.scss']
}
}
},
concat: {
dist: {
src: ['scripts/**/*.js'],
dest: 'dist/js/<%= pkg.name %>.scripts.js'
}
},
uglify: {
dist: {
options: {
sourceMap: false,
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
files: {
'dist/js/<%= pkg.name %>.scripts.min.js': ['dist/js/<%= pkg.name %>.scripts.js']
}
}
},
cssmin: {
minify: {
src: 'dist/css/<%= pkg.name %>.styles.css',
dest: 'dist/css/<%= pkg.name %>.styles.min.css'
}
},
htmlmin: {
dist: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: {
'dist/index.html': 'index.html'
}
}
},
copy: {
main: {
files: [{
expand: true,
cwd: '/',
src: '**/*.html',
dest: 'dist/',
filter: 'isFile',
rename: function (dest, src) {
// Change the path name utilize underscores for folders
return dest + src.replace(/\//g,'_');
}
}],
}
},
clean: {
dist: ['dist/']
},
watch: {
sass: {
files: '**/*.scss',
tasks: ['sass']
},
copy:{
files: '**/*.html',
tasks: ['sass']
}
}
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default',['clean', 'sass', 'concat', 'uglify', 'cssmin', 'htmlmin', 'watch']);
};
我不确定我做错了什么。有人可以解释一下吗?
提前感谢。