我创建了一个程序包,用于导出反应组件。为了生成程序包,我使用了汇总。
现在在以下情况下,ParentComponent渲染ChildComponent,但是有什么方法可以覆盖其默认渲染?
const ChildComponent = () => {
return <div>Hello</div>;
};
const ParentComponent = () => {
return <ChildComponent />;
}
rollup.js
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { uglify } from 'rollup-plugin-uglify';
import replace from 'rollup-plugin-replace';
import json from 'rollup-plugin-json';
import copyFiles from "./rollup.copyfiles.plugin.js"
var config = {
input: 'src/entry.js',
external: ['react', 'prop-types', 'mobx', 'mobx-react', 'react-router', 'react-router-dom', 'arv-reactcomponents', 'react-recaptcha-google', 'isomorphic-fetch', 'react-native-uuid', 'es6-promise'],
output: [{
file: 'bundle/cjs/main.js',
format: 'cjs',
sourcemap: true
}],
plugins: [
json(),
resolve({
jsnext: true,
main: true,
}),
commonjs({
include: 'node_modules/**'
}),
babel({
babelrc: false,
exclude: 'node_modules/**',
"plugins": [
"transform-runtime",
"transform-decorators-legacy"
],
"presets": [
["env", {
"modules": false
}],
"es2017",
"stage-0",
"react"
],
"runtimeHelpers": true
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production')
}),
copyFiles({
input: 'src/component',
output: 'bundle/component',
matches: /.*\.scss$/
}),
copyFiles({
input: 'src/mixins',
output: 'bundle/mixins',
matches: /.*\.scss$/
})
]
}
export default config;