Ember CLI pod 结构迁移

Ember CLI pod structure migration

我刚刚开始将 Ember 用于实际应用程序,并且已经让自己陷入了困境。

我使用以下内容设置我的 environment.js 文件:

modulePrefix: 'appname',
podModulePrefix: 'appname/pods'

但是,这没有用,Ember CLI 继续在 old/normal 结构中生成文件。不幸的是,我什至没有注意到,直到我完成了相当多的工作......因为我很兴奋只是有一个 Ember 应用程序运行! ;)

所以我的问题有两个:

  1. 为什么 podModulePrefix 不起作用?我已经阅读了它,它似乎应该没问题。我可能错过了为什么它不起作用的要点。
  2. 如何将我现有的文件结构迁移到 pod 结构中?是手动操作,还是有可以帮助解决问题的工具?

感谢您的帮助!

我要回答

1- 你应该停止 Ember 然后重新开始,你的代码应该是

 podModulePrefix: 'app/pod', //just an example 

然后开始创建像

这样的测试组件
ember g component test-com --pod

结果会是这样

installing component
  create app/pod/components/test-com/component.js
  create app/pod/components/test-com/template.hbs
installing component-test
  create tests/integration/pod/components/test-com/component-test.js

2- 没办法,您必须简单地创建、复制和粘贴您的代码。

If you would like to use the pods structure as the default for your project, you can set usePods in your .ember-cli config file to true (setting was previously named usePodsByDefault). To generate or destroy a blueprint in the classic type structure while usePods is true, use the --classic flag.

usePods 设置为 true。

// .ember-cli
{
    "usePods": true
}