score:0
&
in shell means that it will run in the background, so maybe your variable declaration is not caught by the build stuff that happens at the same time. The good thing is that you can just prepend the command with the variable declarations.
You could simplify the commands like this:
"serve": "NODE_ENV=development webpack-dev-server --content-base bin/ --devtool eval --progress --colors --hot --inline",
"deploy": "NODE_ENV=production BABEL_ENV=production webpack -p --config webpack.production.config.js"
score:0
You can just use the babel-preset-react-hmre
.
.babelrc
{
"presets": ["react", "es2015", "stage-0"],
"plugins": [
"transform-decorators-legacy"
],
"env": {
"development": {
"presets": ["react-hmre"]
}
}
}
webpack
{
test: /\.js(x?)$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react', 'stage-0'],
plugins: ['transform-decorators-legacy'],
env: {
development: {
presets: ['react-hmre']
}
}
}
}
score:5
It seems that no matter what Babel keeps using the development
section of the env
value specified in .babelrc
. What solved the problem for me, was to use name other than 'development' and set that as the value of BABEL_ENV.
"env": {
"dev": {
"plugins": [
]
},
"production": {
}
}
I use separate conf for development. In plugins I have:
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('development'),
'BABEL_ENV': JSON.stringify('dev')
}
}),
score:8
The only thing that worked for me, is that I wrote -
process.env.NODE_ENV = 'production';
at the beginning of my webpack.config.prod.js file.
Source: stackoverflow.com
Related Query
- Why does production build of React app (with Webpack and Babel) use wrong development env with HMR, which causes errors?
- Why does React require Babel and Webpack to work?
- Unicode characters not showed when bundling and deploying React app with webpack and babel
- How can I build a React app with Webpack and import an assets folder?
- How to determine the order of css in my create react app build with webpack and customize-cra?
- Problem with npm build and babel in React Create App
- Error in production build with Webpack, Babel and React - Error: Cannot find module '@babel/runtime/core-js/get-iterator'
- Unable to build ES6 version of my React App with webpack and babel-preset-env
- Why does Webpack build of React web app fail when project is built in a different folder?
- Uncaught ReferenceError: process is not defined error when converting react (TS) app to PWA with webpack and babel config
- SCRIPT1006: Expected '() React app with webpack and Babel
- Webpack how to build production code and how to use it
- How to set up Babel 6 stage 0 with React and Webpack
- Why is React Webpack production build showing Blank page?
- Why does my React Native app build successfully despite TypeScript compiler error?
- Error using component done with react,redux and react-redux and build with webpack in react application
- How to reduce react app build time and understanding behaviour of webpack when bundling
- Installing Babel to use with React and JSX
- Why does my React app use so much memory?
- google app engine with React and Node: Production setup
- How to use Jest with React and Webpack
- `Invalid mapping` error trying to use babel require hook and polyfill with react jsx transpile
- Why does my React app append the external URL to http://localhost:/<port> and not to ONLY the URL itself?
- Why my react app fails on production build after upgrading to react 16?
- Build version of react app giving wrong links to CSS and JS files
- Why credit card autofill doesn't work when production build but it works with npm start in my react application?
- Build React components with Gulp, Browserify and Babel
- Trying to deploy my REACT Webpack app to heroku. Everything works locally and the heroku build works. But I'm getting a 404 nginx
- Create React App production build succeeds but produces code with errors
- Unable to expose a component library in react with webpack and babel
More Query from same tag
- Get html class name from React component upon mounting
- change profile picture when click in link to the same page
- Will cloning the whole state object in React lead to side-effects?
- How can I disable all typescript type checking?
- TypeError: arr.reduce is not a function
- .keyboard is not a function when used with React
- SSL certificate - disable verification in axios and react
- getting innerHTML from a div after changes through contentEditable in React
- react-bootstrap navbar odd behavior
- Login page doesn't position correctly on bigger screen - React Bootstrap
- How to iterate ArrayVector in reactJS
- React Pubnub Chat. Message dublication or no message at all
- react componentDidMount() Unexpected token, expected ";"
- Default value with react-select, checkboxes not working when I want to post my data having a blank page output
- How to avoid reconnections with socket.io-client and React app?
- React button: how to make it change onClick
- Index routes with nested routes in React-router v3
- Prevent onClick event to happen in all rows instead of one sigle row per click
- How to send response to react after dispatching action
- Passing props to Children component from Parent state- React Router
- How to clear Select / reset Select option into "Select.." / null?
- React redux - issues adding multiple items to an array in state tree object
- useState hook, setState function. Accessing previous state value
- Trimming Draft.js Editor content with the OnBlur event
- When to update state based on previous state in useState hook in React/Typescript
- How to multiply each value in an array of coordinates
- Getting the button and input fields in one line
- Multiple react-table instances on same page
- React + Typescript error for material ui icons
- Trigger onClick event of button on dynamically generated html in ReactJS