我正在通过咕unt声构建角度应用,并且在grunt-dom-munger中面临问题
这是我的Grunt文件配置设置
dom_munger: {
read: {
options: {
read: [
{
selector: 'script', // script[data-concat!="false"]
attribute: 'src',
writeto: 'appjs',
isPath: true
},
{
selector: 'link[rel="stylesheet"]', // link[rel="stylesheet"][data-concat!="false"]
attribute: 'href',
writeto: 'appcss',
isPath: true
}
]
},
src: 'app/index.html'
},
update: {
options: {
remove: ['script[data-remove!="false"]', 'link[data-remove!="false"]'],
append: [
{
selector: 'body',
html: '<script src="app.full.min.js"></script><script src="config.js"></script>'
},
{
selector: 'head',
html: '<link href="favicon.ico" rel="shortcut icon"><link rel="stylesheet" href="assets/css/app.full.min.css">'
}
]
},
src: 'app/index.html',
dest: 'dist/app/index.html'
}
},
cssmin: {
main: {
src: ['temp/app.css', '<%= dom_munger.data.appcss %>'],
dest: 'dist/app/assets/css/app.full.min.css'
}
},
concat: {
main: {
src: ['<%= dom_munger.data.appjs %>', '<%= ngtemplates.main.dest %>'],
dest: 'temp/app.full.js'
}
},
当我运行GRUNT构建时,抛出以下警告/错误
Running "cssmin:main" (cssmin) task
Warning: An error occurred while processing a template (Cannot read property 'appcss' of undefined). Used --force, continuing.
Warning: An error occurred while processing a template (Cannot read property 'appcss' of undefined). Used --force, continuing.
Warning: An error occurred while processing a template (Cannot read property 'appcss' of undefined). Used --force, continuing.
Warning: The "path" argument must be of type string Used --force, continuing.
Running "concat:main" (concat) task
Warning: An error occurred while processing a template (Cannot read property 'appjs' of undefined). Used --force, continuing.
Warning: An error occurred while processing a template (Cannot read property 'appjs' of undefined). Used --force, continuing.
Warning: An error occurred while processing a template (Cannot read property 'appjs' of undefined). Used --force, continuing.
File temp/app.full.js created.
注意:我的源应用程序文件位于/应用程序目录和目标文件夹中/dist/
任何人都可以在我犯错的地方帮助我。
我们在构建时间遇到了相同的问题。经过这么多R&amp; d,我们得到了解决方案。请更改" node_modules/grunt-dom-munger/tasks/dom_munger.js"文件中的" <strong"> 42 。
var relativeTo = path.dirname(grunt.file.expand(f));
to
var relativeTo = path.dirname(grunt.file.expand(f)[0]);