我正在尝试将位于我的Script文件夹中的所有javascript文件动态添加到index.html文件中。为了执行相同的操作,我使用GRUNT来包含文件。 我在grunt.js文件中指定了以下配置:
{
includeSource: {
options: {
basePath: '../../Scripts/app',
baseUrl: '/',
templates: {
html: {
js: '<script src="{filePath}"></script>',
css: '<link rel="stylesheet" type="text/css" href="{filePath}" />',
}
}
},
myTarget: {
files: {
'tmp/index.html': '../../index.html'
}
}
}
}
grunt.loadNpmTasks('grunt-include-source');
grunt.registerTask('default', ['includeSource:myTarget']);
此外,在HTML文件中,我添加了以下语句以包含脚本文件夹中的所有文件:
<!-- include: "type": "js", "files": ["Scripts/**/*.js"] -->
此后,我运行includeSource任务的命令,如下所示: grunt includeSource:myTarget
在运行语句之后,任务完成,它表示创建了一个新文件“tmp / index.html”,就像我在myTarget文件源中指定的那样。但是,创建的文件不包含我在脚本文件夹中的javascript文件。我在这里错过了什么吗?