Comments (5)
This is probably possible without changing .core today using src/app/server/middleware.js
.
from reactium.
Essentially the approach would be to change the webpack
and hmr
middlewares according to your needs.
src/app/server/middleware.js:
const webpack = require('webpack');
const gulpConfig = require('reactium-core/gulp.config');
const webpackConfig = require('reactium-core/webpack.config')(gulpConfig);
const wpMiddlware = require('webpack-dev-middleware');
const wpHotMiddlware = require('webpack-hot-middleware');
let port = gulpConfig.port.proxy;
let pvar = op.get(process.env, 'PORT_VAR', false);
if (pvar) {
port = op.get(process.env, pvar, port);
} else {
port = op.get(process.env, 'APP_PORT', port);
port = op.get(process.env, 'PORT', port);
}
port = Number(port);
const publicPath = `http://localhost:${port}/`;
let compiler;
// Update the webpack configuration to be used for node/express wepback middleware in local dev.
if (process.env.NODE_ENV === 'development') {
webpackConfig.entry.main.unshift( `webpack-hot-middleware/client?path=/__webpack_hmr&quiet=true`);
webpackConfig.plugins.push(new webpack.HotModuleReplacementPlugin());
webpackConfig.output.publicPath = publicPath;
compiler = webpack(webpackConfig);
}
module.exports = expressMiddlewares => expressMiddlewares.map(mw => {
if (process.env.NODE_ENV !== 'development') return mw;
switch(mw.name) {
case 'webpack':
return {
name: 'webpack',
use: wpMiddlware(compiler, {
serverSideRender: true,
path: '/',
publicPath,
}),
};
case 'hmr':
return {
name: 'hmr',
use: wpHotMiddlware(compiler, {
reload: true,
}),
};
default:
return mw;
}
});
from reactium.
Didn't test the above, but that'd be the general approach.
from reactium.
Thats for development mode, correct? In production we aren't using express, in fact the server directory is in the ignore loader list to prevent bundling express.
from reactium.
The part of core you are referencing is only used in local development, to allow webpack to serve live development updates to the browser. The webpack override is used for both. In other words, when you are doing a static build (or node/express production for that matter), that code is not in play.
Your updates to webpack override for the static build should work fine.
from reactium.
Related Issues (11)
- Feature: Local Development - Auto Port
- Action required: Greenkeeper could not be activated 🚨
- Cannot init new full-stack project HOT 1
- Toolkit content styles not reloading on change HOT 3
- add package version to env variables HOT 9
- Optionally Package Styles with Webpack HOT 1
- Rendering Top-Level component in SPA HOT 2
- Beautify Module is not IE11 compatible HOT 1
- "order" attribute in route causing production error HOT 1
- Toolkit Path
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reactium.