簡體   English   中英

將Middleman變量傳遞給grunt文件

[英]pass middleman variable to grunt file

我的中間人模板有一個'id'變量,我將我的html電子郵件工作名稱放入了該變量。

我知道如果將我的中間人erb文件從index.html.erb更改為newName.html.erb,它將輸出該文件作為最終文件名。

我的問題是我的大多數grunt任務都需要我希望它們運行的​​文件名(我嘗試過使用* .html,但僅適用於某些任務),而在啟動grunt之前在grunt文件中沒有進行編輯如果我更改erb文件名,它們將不會執行。

有沒有辦法通過grunt這個'id'變量來命名中間人正在輸出的文件,並將該變量插入各種任務中,以便他們也接受它作為文件名呢?

這是我的咕unt的配置:

grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        // Build html
        middleman: {
            options: {
                useBundle: true
            },
            server: {},
            build: {
                options: {
                    command: "build"
                }
            }
        },
        // Format html file
        prettify: {
            options: {
                // Task-specific options go here.
            },
            one: {
                src: 'build/index.html',
                dest: '_output/index.html'
            }
        },
        // Run the text converter
        execute: {
            simple_target_with_args: {
                options: {
                    // execute node with additional arguments
                    args: ['_output/index.html']
                },
                src: ['node_modules/node-text-converter/converter.js']
            }
        },
        'special-html': {
            compile: {
                files: {
                   '_output/index.html': '_output/index.html',
                }
            }
        },
        'phantomjs_screenshot': {
        main: {
            options: {
                delay: 1000
            },
            files: [{
                expand: true,
                cwd: '_output',
                src: ['**/*.html'],
                dest: '_output/screenshots/',
                ext: '.jpg'
            }]
        }
    }
});

您應該將變量存儲在JSON文件中,然后將其導入Middleman和Grunt中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM