Fuse-box: Webpacket DefinePlugin Like Plugin ?

Created on 19 May 2017  路  3Comments  路  Source: fuse-box/fuse-box

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:

  1. globals setup.
  2. EnvPlugin
  3. ReplacePlugin

all these plugins cannot replace/define a constants inside React JSX files.

Is there any way to do it ?

discussion

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.

All 3 comments

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);
Was this page helpful?
0 / 5 - 0 ratings

Related issues

misantronic picture misantronic  路  3Comments

tomitrescak picture tomitrescak  路  4Comments

danielearwicker picture danielearwicker  路  3Comments

charles-mathieus-jomedia picture charles-mathieus-jomedia  路  4Comments

thepatrick picture thepatrick  路  5Comments