I am code breaking my JavaScript files using React Router and Webpack 2 as follows:
export default { path: '/', component: Container, indexRoute: { getComponent(location, cb) { if (isAuthenticated()) { redirect(); } else { System.import('../landing-page/LandingPage') .then(loadRoute(cb)) .catch(errorLoading); } }, }, childRoutes: [ { path: 'login', getComponent(location, cb) { System.import('../login/Login') .then(loadRoute(cb)) .catch(errorLoading); }, }, { } };
What are the results on this bunch:
public/ vendor.bundle.js bundle.js 0.bundle.js 1.bundle.js 2.bundle.js
This means that the end user receives only the JavaScript that he needs, in accordance with the route in which he is.
The thing is, for the css part, I do not find any resource to do the same thing that I need to break CSS in accordance with the needs of the user.
Is there a way to do this with Webpack 2 and React Router?
reactjs webpack webpack-2 css-modules
Matheus lima
source share