我正在使用grunt来构建我的项目,并具有以下src结构:
app/src/client/pages/user/users.js
app/src/client/pages/user/users.html
app/src/client/pages/project/projects.js
app/src/client/pages/user/projects.html现在,我正在尝试将我的项目构建为如下所示:
app/dist/client/users.html我使用contrib-htmlmin插件,我的grunt配置如下所示:
htmlmin: {
options: {
removeComments: true,
collapseWhitespace: true
},
partials: {
files: [
{
expand: true,
cwd: "app/src/client/pages/*/",
dest: "app/dist/client/",
src: ["*.html"]
}
]
}但这根本不起作用,没有文件被缩小。有什么建议吗?
发布于 2014-08-01 21:11:12
据我所知,Grunt不会在cwd中扩展模式,所以您的选择
cwd: "app/src/client/pages/*/",永远不会转换为匹配目录的数组。
您可以通过启动at this line in the source来遵循我的逻辑来得出这个结论。grunt.file.expandMapping (source here)不会对您的cwd模式调用grunt.file.expand。
这并不意味着你不能自己做。当我的sass文件分布在多个目录中时,我使用以下模式完成了与grunt-contrib-sass类似的工作:
htmlmin: {
options: {
removeComments: true,
collapseWhitespace: true
},
partials: {
files: grunt.file.expand(['app/src/client/pages/*/']).map(function(cwd) {
return {
expand: true,
cwd: cwd,
dest: "app/dist/client/",
src: ["*.html"]
};
}),
}https://stackoverflow.com/questions/25024741
复制相似问题