mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
The old version of prettier we were using didn't support the Flow syntax to access properties in a type using `SomeType['prop']`. This updates `prettier` and `rollup-plugin-prettier` to the latest versions. I added the prettier config `arrowParens: "avoid"` to reduce the diff size as the default has changed in Prettier 2.0. The largest amount of changes comes from function expressions now having a space. This doesn't have an option to preserve the old behavior, so we have to update this.
71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
require('ignore-styles');
|
|
const babelRegister = require('babel-register');
|
|
const proxy = require('http-proxy-middleware');
|
|
|
|
babelRegister({
|
|
ignore: /\/(build|node_modules)\//,
|
|
presets: ['react-app'],
|
|
});
|
|
|
|
const express = require('express');
|
|
const path = require('path');
|
|
|
|
const app = express();
|
|
|
|
// Application
|
|
if (process.env.NODE_ENV === 'development') {
|
|
app.get('/', function (req, res) {
|
|
// In development mode we clear the module cache between each request to
|
|
// get automatic hot reloading.
|
|
for (var key in require.cache) {
|
|
delete require.cache[key];
|
|
}
|
|
const render = require('./render').default;
|
|
render(req.url, res);
|
|
});
|
|
} else {
|
|
const render = require('./render').default;
|
|
app.get('/', function (req, res) {
|
|
render(req.url, res);
|
|
});
|
|
}
|
|
|
|
// Static resources
|
|
app.use(express.static(path.resolve(__dirname, '..', 'build')));
|
|
|
|
// Proxy everything else to create-react-app's webpack development server
|
|
if (process.env.NODE_ENV === 'development') {
|
|
app.use(
|
|
'/',
|
|
proxy({
|
|
ws: true,
|
|
target: 'http://localhost:3001',
|
|
})
|
|
);
|
|
}
|
|
|
|
app.listen(3000, () => {
|
|
console.log('Listening on port 3000...');
|
|
});
|
|
|
|
app.on('error', function (error) {
|
|
if (error.syscall !== 'listen') {
|
|
throw error;
|
|
}
|
|
|
|
var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port;
|
|
|
|
switch (error.code) {
|
|
case 'EACCES':
|
|
console.error(bind + ' requires elevated privileges');
|
|
process.exit(1);
|
|
break;
|
|
case 'EADDRINUSE':
|
|
console.error(bind + ' is already in use');
|
|
process.exit(1);
|
|
break;
|
|
default:
|
|
throw error;
|
|
}
|
|
});
|