Open supersnager opened 4 years ago
I think this can be accomplished by using BABEL_ENV
On Sat, Apr 4, 2020, 4:25 AM Super Snager notifications@github.com wrote:
Sometimes you may want to remove propTypes for production build, but sometimes not. For example when your library is imported in storybook, you want not to remove propTypes, because storybook reads it to show in docs page.
I think, that plugin should support this case - condition string should be configurable.
In storybook scenario wrap condition might look like this:
if (process.env.NODE_ENV !== "production" || process.env.NOT_REMOVE_PROP_TYPES) {
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/issues/191, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABPXTX77PUSBIW6TOAO72DRK34HPANCNFSM4L5YWFDQ .
@lencioni How? Can you explain it further?
I think you could define a storybook env in your Babel config that doesn't include this plugin, and then start storybook with the BABEL_ENV env var set to match.
On Sat, Apr 4, 2020, 10:29 AM Super Snager notifications@github.com wrote:
@lencioni https://github.com/lencioni How? Can you explain it further?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types/issues/191#issuecomment-609045238, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABPXTRZ36AKNEJQIEDKURDRK5G33ANCNFSM4L5YWFDQ .
@lencioni It is not possible to do it in this way. Library is dependency in storybook, is already built and has wrapped prop types:
if (process.env.NODE_ENV !== "production" ) {
Sometimes you may want to remove propTypes for production build, but sometimes not. For example when your library is imported in storybook, you want not to remove propTypes, because storybook reads it to show in docs page.
I think, that plugin should support this case - condition string should be configurable.
In storybook scenario wrap condition might look like this: