I'm trying to wrap all of react-engine and my small react app in a module that can easily be used in another larger express app for example if you export the app variable at the end of this file example/server.js and rename that file react-code.js then make another file server.js with something like this:
import reactCode from './react-code'
import express from 'express';
let app = express();
app.use(reactCode)
const PORT = 3000;
const server = app.listen(PORT, function() {
console.log('Example app listening at http://localhost:%s', PORT);
});
I can easily move around the react piece in a larger express app (ignore that theres a * glob assigned to every route in the example).
The thing I'm having a more hard time including in this modularity is the webpack integration. I was wondering if it was possible to use webpack programmatically and given env flags a piece of middleware could render .bundle.js and serve it directly from express instead of having webpack render a file in a specific public folder. The fixed public folder, and the webpack script prevents a react-engine route / express app from being easily encapsulated.
Wondering general thoughts on this. I'm trying to compartmentalize / organize the react-engine-app portion of a greater app, without too much overhead on integrating webpack.
I'm trying to wrap all of
react-engine
and my small react app in a module that can easily be used in another larger express app for example if you export the app variable at the end of this file example/server.js and rename that filereact-code.js
then make another fileserver.js
with something like this:I can easily move around the react piece in a larger express app (ignore that theres a * glob assigned to every route in the example).
The thing I'm having a more hard time including in this modularity is the webpack integration. I was wondering if it was possible to use webpack programmatically and given
env
flags a piece of middleware could render.bundle.js
and serve it directly from express instead of having webpack render a file in a specific public folder. The fixed public folder, and the webpack script prevents areact-engine
route / express app from being easily encapsulated.Wondering general thoughts on this. I'm trying to compartmentalize / organize the
react-engine-app
portion of a greater app, without too much overhead on integrating webpack.