나는 내 자바 스크립트 파일을 분할 코드를 해요는 다음과 같이 라우터와 웹팩이 반응이 번들 결과CSS 코드 분할과 반작용 라우터
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);
},
},
{ /* etc */
}
};
:
public/
vendor.bundle.js
bundle.js
0.bundle.js
1.bundle.js
2.bundle.js
어떤 그/그녀가있는 경로에 따라 최종 사용자가 자신이 필요로하는 자바 스크립트 만 얻고 있다는 것을 의미합니다.
문제는 : CSS 부분에 대해서는 CSS를 사용자의 필요에 따라 분할하는 것과 같은 일을하는 리소스를 찾지 못합니다.
Webpack 2 및 React Router로 할 수있는 방법이 있습니까?
CSS 코드 분할에 대한 설명서를 보았습니까? https://webpack.js.org/guides/code-splitting-css/ –
@JakobLind 예, 했었습니다. 문서에서 유일한 것은 여러 항목을 갖는 것입니다. 하지만 React Router를 사용하고 하나의 항목 만있는 경우 어떻게 여러 항목을 가질 수 있습니까? –