Build cwd中的Grunt JS文件模式

Build cwd中的Grunt JS文件模式,build,gruntjs,cwd,Build,Gruntjs,Cwd,我正在使用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 htmlmin: {

我正在使用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
htmlmin: {
            options: {
                    removeComments: true,
                    collapseWhitespace: true
            },      
            partials: {
                files: [
                    {
                        expand: true,
                        cwd: "app/src/client/pages/*/",
                        dest: "app/dist/client/",
                        src: ["*.html"]
                    }
                ]
            }
我使用contrib htmlmin插件,我的grunt配置如下所示:

app/dist/client/users.html
htmlmin: {
            options: {
                    removeComments: true,
                    collapseWhitespace: true
            },      
            partials: {
                files: [
                    {
                        expand: true,
                        cwd: "app/src/client/pages/*/",
                        dest: "app/dist/client/",
                        src: ["*.html"]
                    }
                ]
            }
但这根本不起作用,没有文件被缩小。
有什么建议吗?

据我所知,Grunt不会在
cwd
中扩展模式,所以您可以选择

cwd: "app/src/client/pages/*/",
从不转换为匹配目录的数组

你可以按照我的逻辑得出这个结论
grunt.file.expandMapping
()不会在
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"]
            };
        }),
    }

据我所知,Grunt不会在
cwd
中扩展模式,因此您可以选择

cwd: "app/src/client/pages/*/",
从不转换为匹配目录的数组

你可以按照我的逻辑得出这个结论
grunt.file.expandMapping
()不会在
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"]
            };
        }),
    }

为什么文档中没有这个示例?这为我节省了很多时间。为什么文档中没有这个例子?这帮我节省了很多时间。