hmm, i just implemented a simple example of express api server for my own need.
the main concept is:
run the webpack-dev-server in server/index.js, then it will enable/now enable the HotReplacementModule according to the development/production environment.
the webpack-dev-server enables proxy to the API server, easiest way to avoid cross-domain problem while requesting the API on client side.
In production env, run simply npm run start@prod, it will excute npm run build & NODE_ENV=production npm run start, which will build the client's static files and set the server's static path to the webpack build(output) path.
What i haven't done jet:
Babel polyfill for server side. (but personally i consider it as unnecessary, node itself already had the support for most ES6 features, except the module-loader, destructure.. so running server without polyfill will achieve better performance)
more clear structure and organisation of server side
hmm, i just implemented a simple example of express api server for my own need. the main concept is:
npm run start@prod
, it will excutenpm run build & NODE_ENV=production npm run start
, which will build the client's static files and set the server's static path to the webpack build(output) path.What i haven't done jet: