K
K
KnightForce2017-05-08 19:16:44
React
KnightForce, 2017-05-08 19:16:44

How to do without dev server (create-react-app) when using react-router?

I write in React without a dev server. React router, but for convenient development, a local server is useful, like the one created by create-react-app. Because the .html page is not particularly routed without hashHistory (it does not need to be used in the project).
But it is not convenient, I don’t want to shovel the config every time, and in general the project structure is not satisfactory.
Suggest a solution to the problem.
Because in the previous webpack.config I configured everything for myself.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Gushchin, 2017-05-08
@KnightForce

Do you want to deprecate webpack-dev-server? If yes, you can simply use express to distribute statics, and give index.html to all other requests

const app = express()

// раздача статики (css, fonts, images, ...)
app.use('/static/', express.static(__dirname + '/../../public/static'))

app.get('/*', (req, res) => {
  res.send(/* ваш index.html  */)
})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question