【问题标题】:Grunt - Compile Multiple Jade Files using the Pug pluginGrunt - 使用 Pug 插件编译多个 Jade 文件
【发布时间】:2016-09-04 15:45:43
【问题描述】:

我有一个 Laravel 目录结构,我的 Jade 模板位于 /resources/assets/jade/ 文件夹中。

在此文件夹内将有多个子目录,我需要将它们的确切结构复制到 /public/app/ 目录,我的应用将从该目录提供服务。

我还将 Typescript 文件编译到相同的目录结构中,因此在我设置目录布局时复制目录布局非常重要。我似乎无法使用 Grunt Pug 插件成功地做到这一点。任何帮助非常感谢,这是我到目前为止所拥有的:

        module.exports = function(grunt) {
          grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
            pug: {
                    compile: {
                        options: {
                            client: false,
                            pretty: true,
                            data: {
                                debug: false
                            }
                        },
                        files: [{
                            'public/app/index.html': ['resources/assets/jade/index.jade']
                        },
                        {
                            src: "resources/assets/jade/*.jade",
                            dest: "public/app",
                            expand: true,
                            ext: ".html"
                        } ]
                    }
                },
          });
          grunt.loadNpmTasks('grunt-contrib-pug');
          grunt.registerTask('default', ['pug'] );

        };

【问题讨论】:

    标签: node.js gruntjs pug grunt-contrib-jade


    【解决方案1】:

    看起来旧的 grunt-contrib-jade 语法适用于 PUG,尽管我没有在任何地方看到它的文档,所以为了灵巧,这里有什么完美的方法:

            module.exports = function(grunt) {
              grunt.initConfig({
                pkg: grunt.file.readJSON('package.json'),
                pug: {
                       compile: {
                            options: {
                                client: false,
                                pretty: true
                            },
                            files: [ {
                              cwd: "resources/assets/jade",
                              src: "**/*.jade",
                              dest: "public/app",
                              expand: true,
                              ext: ".html"
                            } ]
                        }   
                    },
              });
              grunt.loadNpmTasks('grunt-contrib-pug');
              grunt.registerTask('default', ['pug'] );
    
            };
    

    【讨论】:

      猜你喜欢
      • 2013-07-21
      • 2013-05-05
      • 2016-03-13
      • 2015-09-30
      • 2014-02-02
      • 1970-01-01
      • 2014-11-02
      • 1970-01-01
      • 2015-12-17
      相关资源
      最近更新 更多