I am migrating my project from webpack to fuse-box 2.0. I found a problem that I cannot find a DefinePlugin like replacement.
I have tried the following methods:
all these plugins cannot replace/define a constants inside React JSX files.
Is there any way to do it ?
Hi @hilarycheng !
So this plugin doesn't work for you?
Finally, it works now. I just put the ReplacePlugin like the followings:
CSSPlugin(),
[
BabelPlugin(),
ReplacePlugin({ "VERSION": JSON.stringify("1.0") })
]
Originally, I haven't put the '[ ]' for those two plugins.
Would be nice if there was a plugin like Webpack's Define Plugin that doesn't attach the variables to process.env.[variablename] and instead can be its own variable.
How we did it before we moved to FuseBox was define them:
plugins.push(new webpack.DefinePlugin({
API: JSON.stringify(API),
TEST: "test"
}));
and then in a react component for example if it was needed:
declare var TEST: any;
console.log(TEST);
Most helpful comment
Finally, it works now. I just put the ReplacePlugin like the followings:
CSSPlugin(), [ BabelPlugin(), ReplacePlugin({ "VERSION": JSON.stringify("1.0") }) ]Originally, I haven't put the '[ ]' for those two plugins.