Bra*_*ham 10
这就是我最终把它拉下来的方式:
在我的index.js
文件(我要修改的那个)中,我在应该插入的地方添加了两条注释:
…
import { PointAountCard } from './ponents/PointAountCard';
import { Card } from './ponents/Card';
import { SettingsPanelFooter } from './ponents/SettingsPanelFooter';
// COMPONENT IMPORTS
export {
…
PointAountCard,
Card,
SettingsPanelFooter,
// COMPONENT EXPORTS
};
然后在我的plopfile.js
配置中,我将这两个步骤添加到我的actions
配置中:
module.exports = function (plop) {
plop.setGenerator('ponent', {
actions: [
…
{
path: '../../src/index.js',
pattern: /(\/\/ COMPONENT IMPORTS)/g,
template: 'import { {{name}} } from \'./ponents/{{name}}\';\n$1',
type: 'modify',
},
{
path: '../../src/index.js',
pattern: /(\/\/ COMPONENT EXPORTS)/g,
template: '\t{{name}},\n$1',
type: 'modify',
},
],
description: 'New React Component',
prompts: [
…
],
})
};
所有新组件都会自动添加到index.js
文件中。
更多推荐
文件,Plop
发布评论