From c5d3c3f67d2dac49914b77671e2bedeb086641c1 Mon Sep 17 00:00:00 2001 From: Christophe Hurpeau Date: Mon, 20 Feb 2017 17:32:31 +0100 Subject: [PATCH] fix: sourcemap support for browser --- config/build/webpack.config.client.js | 7 +++++++ src/client/index.jsx | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/config/build/webpack.config.client.js b/config/build/webpack.config.client.js index a41fd9cd..798ff410 100644 --- a/config/build/webpack.config.client.js +++ b/config/build/webpack.config.client.js @@ -37,5 +37,12 @@ export default function clientConfig(options) { entry: appResolve(options.client.serviceWorker), }), ].filter(Boolean), + // Some libraries import Node modules but don't use them in the browser. + // Tell Webpack to provide empty mocks for them so importing them works. + // fs and module are used by source-map-support + node: { + fs: 'empty', + module: 'empty', + }, }, concat); } diff --git a/src/client/index.jsx b/src/client/index.jsx index 58cc1ba3..ef8df864 100644 --- a/src/client/index.jsx +++ b/src/client/index.jsx @@ -4,6 +4,7 @@ import { browserHistory } from 'react-router'; import { useBasename } from 'history'; import RedBox from 'redbox-react'; import { Resolver } from 'react-resolver'; +import { install as installSourceMapSupport } from 'source-map-support'; /* eslint-disable import/no-extraneous-dependencies */ import routes from '__app_modules__routes__'; @@ -19,6 +20,10 @@ import App from './components/App'; // eslint-disable-next-line import/no-extraneous-dependencies const reducers = require('__app_modules__redux_reducers__'); +if (process.env.NODE_ENV !== 'production') { + installSourceMapSupport({ environment: 'browser' }); +} + function render(history, store, appRoutes, element) { const insertCss = ({ _insertCss }) => _insertCss(); Resolver.render(