A lightweight solution for the server-side rendering of webpack-built applications.
With webpack, we can require any files by using loaders:
// CSS Modules// @seeimport style from './css/style.css';// Require a image file<img = />
But you'll get an error in server-side rendering, because it is not supported by Node.js.
webpack-isomorphic is a lightweight, easy-to-use solution to solve this issue, and make your client-side codes work on server too.
$ npm install --save webpack-isomorphic
const IsomorphicPlugin = ;const isomorphicPlugin =extensions: 'jpg' 'png' 'gif' 'css';moduleexports =// The base directory of your source filescontext: __dirname + '/src'// ...plugins://...isomorphicPlugin;
const webpackIsomorphic = ;// The base directory of your built fileswebpackIsomorphic;//...
See the example project for more details.