Select the development interface address according to npm start,
npm run build select the production environment address
Select the development interface address according to npm start,
npm run build select the production environment address
1.start and build start different webpack configuration files
2. Define some environment variables in different webpack configuration files, using webpack define plugin
3. Distinguish url
Development environment:
"dev": "cross-env NODE_ENV=development babel-node. / server.js",
package
"build": "npm run clean & & npm run build:prod"
"build:dev": "cross-env NODE_ENV=development webpack-- colors-- config-- progress",
"build:prod": "cross-env NODE_ENV=production webpack-p-colors-progress-- optimize-minimize",
production environment:
"start": "cross-env NODE_ENV=production babel-node. / server.js",
as above, use cross-env NODE_ENV=xxxxxxx to determine the environment.
< H2 > then assign different addresses according to the environment at the location of the configured address < / H2 > if you use axios to process the request, you can write: in js code:
axios.defaults.baseURL = process.env.NODE_ENV = = 'development'?'
creat-react-app
are all ready for you
process.env.NODE_ENV = development
Development Environment
process.env.NODE_ENV = production
production Environment if(process.env.NODE_ENV = 'development'){
console.log('')
}else if(process.env.NODE_ENV = 'production'){
console.log('')
}
Previous: What if there is too much content to see the first half of the python after running it?
Next: WeChat Mini Programs input box how to prohibit pasting?
1. The data interface is http: www.xxx.com api.paper data under this interface, I use webpack-devServer to configure proxy, but error 404not found is reported on the page. 2.proxy: { manage : { target: http: www.xxxx.com...
webpack found no problems when packaging local development. When the project was to be deployed, the package compilation was happily delivered to the back-end staff. however, there is an unexpected situation in which all dependencies referenced from no...
react-router-dom finally renders the Link as a tag ( _ `). This is the Link? that .open-search a {} serves. ...
wrote a form in ant.design and found that the request to upload the component was inexplicably interrupted, resulting in the picture not being uploaded. after debugging, it is found that the component s setSteta ({loading: true}) method causes the c...
here s the thing! the project uses react + axios , and token needs to be set in header for axios to send requests. The problem with is that token is returned from the login api interface. So obviously, this token is worth saving as a global variab...
description setState updates state through a queue mechanism. When setState is executed, the state that needs to be updated will be merged and put into the status queue, instead of updating this.state immediately. The queue mechanism can upd...
it is very common for an interview question. Although a large number of theoretical answers are found in the evening, I want to know how to separate the front and rear ends in practical projects . the concept of ssr server rendering has always been vag...
want to embed a plug-in in modal, but you need to get the dom node tag. How to get the ref and ReactDOM.findDOMNode methods have been tried, and the result is null parent component: < AddUserWin ref= "AddUserWin " visible= {state.visible} title= {s...
1. Traditional setting styles can be implemented using a similar selector below div p { font-size: 30px; color: -sharpeee; } <div> aaa aaa aaa aaa < div> 2. In React, is it possible to use a css selector similar t...