我使用 webapp-generator 启动了一个yeoman
项目,现在我想在我的项目中添加一些PHP。
我该怎么做才是这样:
grunt build
; dist/
?grunt server
目录中观看/更新
醇>
答案 0 :(得分:4)
我让它使用以下修改:
在 grunt.initConfig({...})中,我在watch
的任务配置项中添加了一个条目:
copyPhp: {
files: [
'<%= yeoman.app %>/*.php'
],
tasks: ['copy:php']
}
然后我更新了copy
的任务配置 - 添加了php
条目 - 因此它与copy:php
中定义的任务copyPhp
相匹配:
copy: {
dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{ico,txt}',
'*.{php,phpc}',
'.htaccess',
'images/assets/{,*/}*.{png,jpg,jpeg}',
'images/{,*/}*.{webp,gif}',
'styles/fonts/*'
]
}]
},
php: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.dist %>',
src: [
'*.{php,phpc}',
]
}]
}
},
你还可以看到,在dist
中,我添加了一行来将PHP文件复制到dist目录:
'*.{php,phpc}',
我还在livereload
配置中添加了一行。 Howerver,因为我使用Apache而不是使用grunt-php的内部服务器,这是毫无意义的,需要更多的工作。
'<%= yeoman.app %>/*.php',