3
Reactコンポーネントの分割を別々のファイルに再作成することはできません。 0.js
、1.js
、2.js
などのコードを分割してbundle.jsファイルを減らします。誰もがこの結果がどのように作られるのか知っていますか?私はChunkManifest
とwebpack-manifest
プラグインでそれを作り直そうとしましたが、それはできません。どんなアドバイスも素晴らしいだろう!ウェブパック "0.js" "1.js"などに反応成分を分割する
routes.js
function errorLoading(err) {
console.error('Dynamic page loading failed', err);
}
function loadRoute(cb) {
return (module) => cb(null, module.default);
}
export default [
{
path: '/',
component: App,
childRoutes: [
{
path: 'signup',
getComponent(location, cb) {
System.import('./modules/App/components/Authentication/Login.js')
.then(loadRoute(cb))
.catch(errorLoading);
}
},
{
path: 'verify',
getComponent(location, cb) {
System.import('./modules/App/components/Authentication/Verify.js')
.then(loadRoute(cb))
.catch(errorLoading);
}
},
{
path: 'password-reset',
getComponent(location, cb) {
System.import('./modules/App/components/Authentication/PasswordReset.js')
.then(loadRoute(cb))
.catch(errorLoading);
}
},
{
path: 'new-password',
getComponent(location, cb) {
System.import('./modules/App/components/Authentication/NewPassword.js')
.then(loadRoute(cb))
.catch(errorLoading);
}
}
]
}
]
素晴らしいです!私はこのリンク 'https:// github.com/ReactTraining/react-router/blob/master/examples/huge-apps'を調べて、あなたに戻ってきます:) – Clement
私はリンク' https:// github .com/ReactTraining/react-router/blob/master/ex amples/huge-apps'とそれがうまくいった! :) – Clement
以前のリンクが壊れているだけで、Googleの "巨大なアプリケーションreactjs"、私はこれを発見しました:(それは元のリンクのコピーが含まれています)https://github.com/echenley/react-router-huge-apps-refactor – pdem