我有以下问题:
我正在尝试在 php 中添加路由 js 文件。 在 html 文件中完美运行。
为什么不在 php 文件中工作?
尝试:
grunt bower-install
错误:
Verifying property bower-install.app.src exists in config...OK
Reading bower.json...OK
Parsing bower.json...OK
Warning: Cannot read property 'block' of undefined Use --force to continue.
代码:
bower: {
dev: {
dest: './components'
},
},
'bower-install': {
app: {
src: ['template.php']
},
},
}
自一周前就有一个问题,但那里没有回应。 https://github.com/stephenplusplus/grunt-bower-install/issues/33
最佳答案
就像@SimonBoudrias 说的那样。您必须转到以下文件路径:
node_modules/grunt-bower-install/node_modules/wiredep/lib/inject-dependencies.js
添加到fileTypesDefaults对象,对象php
var fileTypesDefault = {
html: {
block: /(([\s\t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
detect: {
js: /<script.*src=['"](.+)['"]>/gi,
css: /<link.*href=['"](.+)['"]/gi
},
replace: {
js: '<script src="{{filePath}}"></script>',
css: '<link rel="stylesheet" href="{{filePath}}" />'
}
}, php: {
block: /(([\s\t]*)<!--\s*bower:*(\S*)\s*-->)(\n|\r|.)*?(<!--\s*endbower\s*-->)/gi,
detect: {
js: /<script.*src=['"](.+)['"]>/gi,
css: /<link.*href=['"](.+)['"]/gi
},
replace: {
js: '<script src="{{filePath}}"></script>',
css: '<link rel="stylesheet" href="{{filePath}}" />'
}
},
yaml: {
block: /(([\s\t]*)#\s*bower:*(\S*))(\n|\r|.)*?(#\s*endbower)/gi,
detect: {
js: /-\s(.+)/gi,
css: /-\s(.+)/gi
},
replace: {
js: '- {{filePath}}',
css: '- {{filePath}}'
}
}
};
问候
关于javascript - grunt bower-install 到 php 文件中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20914130/