score:12
Accepted answer
your application's process.env.node_env
variable needs to be set to production
within webpack's build script. react's optimizing performance documentation instructs webpack users to do this using webpack's defineplugin.
new webpack.defineplugin({
'process.env.node_env': json.stringify('production')
})
while it seems that the -p
option should set process.env.node_env
to production
, there is a caveat explained in webpack's specifying the environment documentation that this is not set withtin webpack's build script (for what its worth, many developers have reported this as an issue).
Source: stackoverflow.com
Related Query
- webpack-bundle-analyzer shows webpack -p does not remove development dependency react-dom.development.js
- Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema
- Development server of create-react-app does not auto refresh
- Get Webpack not to bundle files
- React Native does not support development on Windows (yet)?
- Does webpack remove custom variables or event listeners attached to `window` in production?
- Webpack 4 and react loadable does not seems to create correct chunk for server side rendering
- Why does production build of React app (with Webpack and Babel) use wrong development env with HMR, which causes errors?
- How do I resolve peer dependency error: The package react@15.3.2 does not satisfy its siblings' peerDependencies requirements
- Webpack 4 devtool option does not work with webpack-dev-server
- React from NPM cannot be used on the client because 'development' is not defined. The bundle was generated from Webpack
- Does the use of es6 named imports reduce the bundle size when using webpack
- JSDoc does not work in local package in a Lerna monorepo project using webpack dev server but works when released to package registry
- Webpack does not load "asset/resource" type
- React useEffect hook does not fire when prop dependency changes
- Webpack error: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema
- Bundler does not load automatically (No bundle URL present error)
- Webpack css-loader does not resolve aliases
- Webpack resolve.alias does not work with VS Code IntelliSense
- React lazy does not cause splitting bundle in chunks
- webpack 4 : bundle js not found
- Webpack not generating bundle when used with Webpack Dev Server
- How to reduce webpack bundle in development mode?
- React test with jest does not honor moduleNameMapper from webpack aliases
- webpack dev server does not show the content
- Webpack does not copy the images that i use into react components
- Webpack successfully compiled but does not show output in browser
- Webpack does not see the absolute path
- TransitionGroup does not remove element from DOM
- Electron frameless Browser Window does not completely remove entire frame/title bar on Mac
More Query from same tag
- Jest - Create React App - Axios: test get mocked
- Can't render html tags in a template string in react.js
- iOS - App crashes only after installation while configuring Firebase
- Where should I put the state for two components that are only rendered together in the router component?
- How to give the rest of letters default color
- execute a function after many setStates finish updating
- Impossible to debug error while packaging Electron React app after adding Redux but works perfectly in developement
- Getting the ref from a dynamic component when using Redux, React and react-router-dom 4.x
- How to set a js property in getDerivedStateFromProps?
- Extract Redux Store/State as Selector
- React Router: How to redirect to a different component when a link/button is clicked?
- the whole text gets cleared when trying to clear the selected word or character
- How to upgrade Polaris?
- How do I change the state to a different object within an array of objects in a Redux Reducer
- RHF not resetting values in an MUI checkbox group
- Using reducer state inside useEffect
- support for the experimental syntax 'jsx' isn't currently enabled laravel 8
- React Router doesn't change the component
- How do I insert the following code to format the date time before I export to excel?
- Not able to change padding of material UI Select component
- How to detect placeholder text is overflowing in an input field?
- Why does useEffect dependencies on destructed props cause maximum update exceeded?
- Pass in a <li> when there is data with ternary operator in React
- Is it a bad idea to use CustomEvent in a react global component like a snackbar in the AppRoot?
- ReactJS - Is there a way to trigger a method by pressing the 'Enter' key inside <input/>?
- Problem in game lifecycle with React-Hooks
- Uncaught TypeError: props.users.map is not a function
- Change initial text color rendered in React CurrencyInput
- Ipify Getting Blocked By Cors. How do I get it be allowed?
- react-map-gl Style Uncaught Error: Style is not done loading