Grunt bake 文件包含无法读取文件
Grunt bake file include cannot read file
我的根目录中有以下 index.html
当我 运行 g运行t 我得到以下错误:
Verifying property bake.my_target exists in config...OK
Files: index.html -> dist/index.html
Options: content="content.json", section=null, semanticIf=false, basePath="", transforms={}, parsePattern={}, variableParsePattern={}, removeUndefined
Reading content.json...OK
Parsing content.json...OK
Reading index.html...OK
Reading /includes/test.html...ERROR
Warning: Unable to read "/includes/test.html" file (Error code: ENOENT). Use --force to continue.
这是我的 gruntfile.js:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
},
bake: {
my_target: {
options: {
content: "content.json"
},
files: {
"dist/index.html": "index.html"
}
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks( "grunt-bake" );
// Default task(s).
grunt.registerTask('default', ['uglify', 'bake']);
};
我做错了什么。我只是按照 link 中的文档进行操作:https://www.npmjs.com/package/grunt-bake
如果将烘焙文件放在文件夹的根目录下,grunt-bake
似乎存在包含路径解析的错误。尝试将 index.html 放入某个文件夹,例如 'src/index.html' - 这对我有用(浪费了几个小时之后) .
grunt-bake
的源代码包含这一行,因此它总是将 '/' 放入 "include" 文件路径 -我想这就是为什么它不适用于根文件夹中的文件的原因:
directory( filePath ) + "/" + includePath
我的根目录中有以下 index.html
当我 运行 g运行t 我得到以下错误:
Verifying property bake.my_target exists in config...OK
Files: index.html -> dist/index.html
Options: content="content.json", section=null, semanticIf=false, basePath="", transforms={}, parsePattern={}, variableParsePattern={}, removeUndefined
Reading content.json...OK
Parsing content.json...OK
Reading index.html...OK
Reading /includes/test.html...ERROR
Warning: Unable to read "/includes/test.html" file (Error code: ENOENT). Use --force to continue.
这是我的 gruntfile.js:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'src/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
},
bake: {
my_target: {
options: {
content: "content.json"
},
files: {
"dist/index.html": "index.html"
}
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks( "grunt-bake" );
// Default task(s).
grunt.registerTask('default', ['uglify', 'bake']);
};
我做错了什么。我只是按照 link 中的文档进行操作:https://www.npmjs.com/package/grunt-bake
如果将烘焙文件放在文件夹的根目录下,grunt-bake
似乎存在包含路径解析的错误。尝试将 index.html 放入某个文件夹,例如 'src/index.html' - 这对我有用(浪费了几个小时之后) .
grunt-bake
的源代码包含这一行,因此它总是将 '/' 放入 "include" 文件路径 -我想这就是为什么它不适用于根文件夹中的文件的原因:
directory( filePath ) + "/" + includePath