我最终将dist 符号链接到src,因为我们需要 Yeoman 来编译 SCSS 和 CoffeScript 文件。当你yeoman build 创建dist 目录时,这里的无赖是yeoman server 无法运行。另外 bummerish 是当你再次yeoman server 时,它会清理dist 目录。
我计划为 Trigger 的生成器创建一个 yeoman 生成器,并添加一些模仿我在使用 Sinatra 测试和开发时创建的 Rakefile 任务的任务(例如 yeoman simulator、yeoman device、@ 987654332@).
编辑:我现在已经直接向我的gruntfile.js 添加了一些任务。我添加了grunt-contrib-copy 并添加了以下子任务。
copy: {
app: {
files: {
"src/": "app/**", // core app files
},
},
compass: {
files: {
"src/styles/": "temp/styles/**", // drop in the compiled coffeescript
}
},
coffee: {
files: {
"src/scripts/": "temp/scripts/**" // drop in the compiled scss
}
}
},
我将这些任务添加到适当的监视命令中,并添加了一个新监视来监视app 目录。
watch: {
coffee: {
files: 'app/scripts/**/*.coffee',
tasks: 'coffee copy:coffee reload'
},
compass: {
files: [
'app/styles/**/*.{scss,sass}'
],
tasks: 'compass copy:compass reload'
},
app: {
files: [
'app/**/*.{html,png,json,css,js}'
],
tasks: 'copy:app'
},
}
现在yeoman server 调用yeoman watch,使src 保持最新状态。
我还引入了grunt-shell 来执行以下操作。
shell: {
forge_build: {
command: 'forge build ios 2>&1 | tee output',
stdout: true
},
forge_run_device: {
command: 'forge run ios --ios.device device',
stdout: true
},
forge_run: {
command: 'forge run ios',
stdout: true
}
}
并创建一些任务,例如:
grunt.registerTask("sim", 'copy shell:forge_build shell:forge_run');
grunt.registerTask("device", 'copy shell:forge_build shell:forge_run_device');
我对它并不完全满意,但它让我可以继续运行 yeoman server 并放到其他地方的控制台并运行 yeoman device 以在设备中启动它。它还将src 目录保存在可以签入的位置。
最终我会将它移到一个 yeoman 插件中,并添加一些更具体的构建任务来清理适当目标(例如 iOS、Android)的 src 目录,以保持目录大小较小。
编辑:我创建了 grunt-forge 来帮助在 Yeoman 内部运行 forge。我还写了一些关于创建 a more terse output for `forge 的博客。