2015-04-16 30 views
1

我的問題如下;我正在使用grunt-include-source(https://www.npmjs.com/package/grunt-include-source)將我的腳本和css包括到我的index.html中,這個工作正常,但我只能指定一個basepath,並且我想爲dev和production都設置這個插件。 (使用相同的文件夾結構,所以什麼都不會在我的index.html改變IM,唯一不同的是,在我的生產串連)grunt-include-source多種配置

includeSource: { 
    options: { 
    basePath: 'dev' 
    }, 
    myTarget: { 
    files: { 
     'dev/index.html': 'app/index.html' 
    } 
    } 

}, 

上面的代碼工作正常,現在我想有2個不同的配置,開發:但在運行任務時includeSource這樣的事情不工作

includeSource: { 
    dev: { 
    options: { 
     basePath: 'dev' 
    }, 
    myTarget: { 
     files: { 
     'dev/index.html': 'app/index.html' 
     } 
    } 
    }, 
    prod: { 
    options: { 
     basePath: 'prod' 
    }, 
    myTarget: { 
     files: { 
     'prod/index.html': 'app/index.html' 
     } 
    } 
    } 
}, 

的index.html:

<!-- include: "type": "js", "files": "scripts/*.js" --> 

任何人都可以幫助我如何我就能夠實現這一目標?

編輯:只是要一個多一點清晰,即時運行此腳本我建立了生產或開發完成後,對於我的督促/ dev的所有腳本都存儲在腳本/

親切的問候後,

+0

您如何運行'prod'任務? – URL87

回答

1

只須配置您的任務是這樣,而不是:

includeSource: { 
    options: { 
    basePath: 'dev/' 
    }, 
    dev: { 
    files: { 
     'dev/index.html': 'app/index.html' 
    } 
    }, 
    prod: { 
    options: { 
     basePath: 'dist/' 
    }, 
    files: { 
     'dist/index.html': 'app/index.html' 
    } 
    } 
}, 
+0

這解決了這個問題!非常感謝你! – Geo

+0

然後如何使用它的開發?只需輸入任務 - 「includeSource:dev'? – URL87