mirror of https://github.com/alibaba/ice.git
fix: move types to template
This commit is contained in:
parent
ca3fa80519
commit
d57575d665
|
|
@ -1,5 +1,6 @@
|
|||
import * as path from 'path';
|
||||
import * as fse from 'fs-extra';
|
||||
import * as ejs from 'ejs';
|
||||
import Generator from './generator';
|
||||
|
||||
export default async (api) => {
|
||||
|
|
@ -11,12 +12,20 @@ export default async (api) => {
|
|||
const appStoreTemplatePath = path.join(templatePath, 'appStore.ts.ejs');
|
||||
const pageStoreTemplatePath = path.join(templatePath, 'pageStore.ts.ejs');
|
||||
const pageStoresTemplatePath = path.join(templatePath, 'pageStores.ts.ejs');
|
||||
const typesTemplatePath = path.join(templatePath, 'types.ts.ejs');
|
||||
const projectType = getValue('PROJECT_TYPE');
|
||||
|
||||
// copy types/index.ts to .ice/store/index.ts
|
||||
await fse.copy(path.join(__dirname, '..', 'src/types'), path.join(targetPath, './store'));
|
||||
// TODO: 考虑合并为一个
|
||||
applyMethod('addIceTypesExport', { source: './store', specifier: '{ IStore }', exportName: 'store?: IStore' });
|
||||
applyMethod('addIceTypesExport', { source: './store/icestore' });
|
||||
|
||||
// render template/types.ts.ejs to .ice/store/types.ts
|
||||
const typesTemplateContent = fse.readFileSync(typesTemplatePath, 'utf-8');
|
||||
const typesTargetPath = path.join(targetPath, 'store', 'types.ts');
|
||||
const content = ejs.render(typesTemplateContent);
|
||||
fse.ensureFileSync(typesTargetPath);
|
||||
fse.writeFileSync(typesTargetPath, content, 'utf-8');
|
||||
applyMethod('addIceTypesExport', { source: './store/types' });
|
||||
|
||||
onGetWebpackConfig(config => {
|
||||
if (command === 'build') {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import * as types from '$ice/appStore';
|
||||
import * as types from '../appStore';
|
||||
|
||||
export type IRootDispatch = types.IRootDispatch;
|
||||
export type IRootState = types.IRootState;
|
||||
Loading…
Reference in New Issue