You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reason to enhance/problem with existing solution webpack/webpack.config.ts preload all different environment configs that may result in running unintended code.
For example, our team uses dotenv-webpack for injecting env variables during the build process.
We enable a safe check with .env.example to ensure env variables are all set. Since this is done whenever we load webpack plugin config, so we need to make sure only the desired webpack config is loaded, otherwise, we will get a warning or build failed because the production plugin config is also loaded in local development environment and apparently we don't have .prod.env in local(unless we make a fake one to fix this issue)
module.exports = {
...
plugins: [
new Dotenv({
path: './server/.dev.env'
safe: './server/.env.example', // load '.env.example' to verify the '.env' variables are all set. Can also be a string to a different file.
})
]
...
};
Suggested enhancement
I already fixed this for my team couple months ago. But I didn't realize we are actually using reactGo as project starter, which was setup 2 years ago. For fixing that, I just change all config render variables to functions, and use ifs to make sure we only generate the desired webpack config each time.
Enhancement
Reason to enhance/problem with existing solution
webpack/webpack.config.ts
preload all different environment configs that may result in running unintended code.For example, our team uses dotenv-webpack for injecting env variables during the build process.
We enable a safe check with .env.example to ensure env variables are all set. Since this is done whenever we load webpack plugin config, so we need to make sure only the desired webpack config is loaded, otherwise, we will get a warning or build failed because the production plugin config is also loaded in local development environment and apparently we don't have .prod.env in local(unless we make a fake one to fix this issue)
Suggested enhancement
I already fixed this for my team couple months ago. But I didn't realize we are actually using reactGo as project starter, which was setup 2 years ago. For fixing that, I just change all config render variables to functions, and use ifs to make sure we only generate the desired webpack config each time.
Like so
Pros
Won't preload all configs, and only generate desired webpack config each time,
Cons
looks a bit clutter, but need very little maintenance.
The text was updated successfully, but these errors were encountered: