How to use Razzle with BrowsersList? #1698
-
|
Hello! In my Razzle app (TS + React) I tried to put different browserslist configuration in package.json but the bundle size did not change significantly (less than 30 B of changes in the bundle). Is it sure that the configuration from package.json is all I need to change how WebPack produces the bundle? Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 13 comments 7 replies
-
|
Browserslist only affects postcss, but should be enough to change package.json |
Beta Was this translation helpful? Give feedback.
-
|
Should affect babel too but does not now i think, babel loader needs fixing in razzle it seems |
Beta Was this translation helpful? Give feedback.
-
|
https://github.com/jaredpalmer/razzle/blob/master/packages/razzle/config/loadRazzleConfig.js#L44 So you can pass it down to the babel preset by modifying babelrule |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
use modifyWebpackOptions razzleOptions.browserslist https://razzlejs.org/docs/customization#extending-webpack |
Beta Was this translation helpful? Give feedback.
-
|
Hm, my idea won't work ... :( https://babeljs.io/docs/en/babel-preset-env#browserslist-integration |
Beta Was this translation helpful? Give feedback.
-
|
Or, maybe .. webpackOptions.babelRule.options['preset-env'].targets = razzleOptions.browserslist |
Beta Was this translation helpful? Give feedback.
-
|
But only if target is web |
Beta Was this translation helpful? Give feedback.
-
|
modifyWebpackOptions not Config 😀 |
Beta Was this translation helpful? Give feedback.
-
|
And babelRule.use[0].options |
Beta Was this translation helpful? Give feedback.
-
|
I looked closer at it, have been giving you bad advice, has to be done in .babelrc ;) |
Beta Was this translation helpful? Give feedback.
-
|
https://razzlejs.org/docs/customization#customizing-babel-config |
Beta Was this translation helpful? Give feedback.
-
{
"presets": [
[
"razzle/babel",
{
"preset-env": {"targets": "> 0.25%, not dead"},
}
]
]
} |
Beta Was this translation helpful? Give feedback.
{ "presets": [ [ "razzle/babel", { "preset-env": {"targets": "> 0.25%, not dead"}, } ] ] }