使用 grunt-html-build
Using grunt-html-build
我在尝试 运行 html-g运行t-build 时遇到错误 Warning: undefined is not a function Use --force to continue.
。以下是更多信息,如有任何帮助,我们将不胜感激:
$ grunt htmlbuild --verbose
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build, default
Running tasks: htmlbuild
Loading "grunt-html-build" plugin
Registering "/home/path/node_modules/grunt-html-build/tasks" tasks.
Loading "build-html.js" tasks...OK
+ htmlbuild
Running "htmlbuild" task
Running "htmlbuild:dist" (htmlbuild) task
Verifying property htmlbuild.dist exists in config...OK
Files: path/to/css/css.html -> path/to/css/css.html
Options: beautify=false, logOptionals=false, relative, scripts={}, styles={"critical":"path/to/css/critical.css"}, sections={}, data={}, parseTag="build"
Reading path/to/css/css.html...OK
Reading path/to/css/critical.css...OK
Warning: undefined is not a function Use --force to continue.
Aborted due to warnings.
我的 G运行t 配置(我使用的是 load-g运行t-config,所以它存储在一个单独的文件中):
module.exports = function(grunt, options) {
return {
dist: {
src: 'path/to/css/css.html',
dest: 'path/to/css/css.html',
options: {
styles: {
critical: 'path/to/css/critical.css'
}
}
}
};
};
更详细的错误:
TypeError: undefined is not a function
at Object.validators.validate (/home/node_modules/grunt-html-build/tasks/build-html.js:196:44)
at /home/node_modules/grunt-html-build/tasks/build-html.js:245:39
at Array.forEach (native)
at transformContent (/home/node_modules/grunt-html-build/tasks/build-html.js:242:14)
at /home/node_modules/grunt-html-build/tasks/build-html.js:306:27
at Array.forEach (native)
at /home/node_modules/grunt-html-build/tasks/build-html.js:295:22
at Array.forEach (native)
at Object.<anonymous> (/home/node_modules/grunt-html-build/tasks/build-html.js:291:20)
at Object.<anonymous> (/home/node_modules/grunt/lib/grunt/task.js:264:15)
所以问题是我在同一个 HTML 文件。
g运行t-html-build 看到了我的构建标签:
<!-- build:css path/to/css/ie8.min.css -->
<link rel="stylesheet" href="path/to/css/ie8.css">
<link rel="stylesheet" href="path/to/css/print-new.css" media="print">
<!-- endbuild -->
而且不知道怎么处理build:css
为了解决这个问题,我将两个文件分成不同的 HTML 包含,这样任务就可以 运行 分开。
将 lodash 从 3.x 升级到 4.x
后,我开始遇到同样的问题
将 lodash 降级为 3.x 为我修复了它,因此它似乎是与 grunt-usemin 和 lodash 4.x
的兼容性问题
我在尝试 运行 html-g运行t-build 时遇到错误 Warning: undefined is not a function Use --force to continue.
。以下是更多信息,如有任何帮助,我们将不胜感激:
$ grunt htmlbuild --verbose
Initializing
Command-line options: --verbose
Reading "Gruntfile.js" Gruntfile...OK
Registering Gruntfile tasks.
Initializing config...OK
Loading "Gruntfile.js" tasks...OK
+ build, default
Running tasks: htmlbuild
Loading "grunt-html-build" plugin
Registering "/home/path/node_modules/grunt-html-build/tasks" tasks.
Loading "build-html.js" tasks...OK
+ htmlbuild
Running "htmlbuild" task
Running "htmlbuild:dist" (htmlbuild) task
Verifying property htmlbuild.dist exists in config...OK
Files: path/to/css/css.html -> path/to/css/css.html
Options: beautify=false, logOptionals=false, relative, scripts={}, styles={"critical":"path/to/css/critical.css"}, sections={}, data={}, parseTag="build"
Reading path/to/css/css.html...OK
Reading path/to/css/critical.css...OK
Warning: undefined is not a function Use --force to continue.
Aborted due to warnings.
我的 G运行t 配置(我使用的是 load-g运行t-config,所以它存储在一个单独的文件中):
module.exports = function(grunt, options) {
return {
dist: {
src: 'path/to/css/css.html',
dest: 'path/to/css/css.html',
options: {
styles: {
critical: 'path/to/css/critical.css'
}
}
}
};
};
更详细的错误:
TypeError: undefined is not a function
at Object.validators.validate (/home/node_modules/grunt-html-build/tasks/build-html.js:196:44)
at /home/node_modules/grunt-html-build/tasks/build-html.js:245:39
at Array.forEach (native)
at transformContent (/home/node_modules/grunt-html-build/tasks/build-html.js:242:14)
at /home/node_modules/grunt-html-build/tasks/build-html.js:306:27
at Array.forEach (native)
at /home/node_modules/grunt-html-build/tasks/build-html.js:295:22
at Array.forEach (native)
at Object.<anonymous> (/home/node_modules/grunt-html-build/tasks/build-html.js:291:20)
at Object.<anonymous> (/home/node_modules/grunt/lib/grunt/task.js:264:15)
所以问题是我在同一个 HTML 文件。
g运行t-html-build 看到了我的构建标签:
<!-- build:css path/to/css/ie8.min.css -->
<link rel="stylesheet" href="path/to/css/ie8.css">
<link rel="stylesheet" href="path/to/css/print-new.css" media="print">
<!-- endbuild -->
而且不知道怎么处理build:css
为了解决这个问题,我将两个文件分成不同的 HTML 包含,这样任务就可以 运行 分开。
将 lodash 从 3.x 升级到 4.x
后,我开始遇到同样的问题将 lodash 降级为 3.x 为我修复了它,因此它似乎是与 grunt-usemin 和 lodash 4.x
的兼容性问题