next.js 收集文件中的所有导入

vsnjm48y  于 2022-11-05  发布在  其他
关注(0)|答案(1)|浏览(152)

在allExports.js中收集所有的导入文件,然后在需要的时候调用,这是个好主意吗?我的主要目标是从一个地方查看和控制所有的文件...
它看起来很酷,代码很清晰,但是这种方式会导致加载速度或安全性不好吗?我不能确定...如果有人有想法,我将不胜感激
_app.js的开头类似于:

import {React,App,Head,thunk,Provider,composeWithDevTools,compose,applyMiddleware,createStore,AuthControl,MyLoading,Header,Footer,MainChat,Mystore,Languages} from 'allExports';

这是出口:

// SYSTEM EXPORTS START

export { default as React }     from 'react';
export { Component }            from 'react';
export { default as axios }     from 'axios';

export { default as Head }      from 'next/head';
export { default as App }       from 'next/app';
export { default as Image }     from 'next/image';
export { default as Link }      from 'next/link';
export { default as Script }    from 'next/script';

export { default as thunk }     from 'redux-thunk';

export { Provider }             from 'react-redux';
export { connect }              from 'react-redux';
export { composeWithDevTools }  from 'redux-devtools-extension';
export { compose,applyMiddleware,legacy_createStore as createStore} from 'redux';

// Stores
export { chatStatus,updateUser,getMyUsers } from 'store/actions/rootaction';

// SYSTEM EXPORTS FINISH AND USER EXPORT START

export { default as Mystore }       from 'store/store';
export { default as AuthControl }   from 'Middleware/AuthControl';

export { default as MyChat }        from 'a-my-npms/my-chat/MyChatContainer';
export { default as ChatButton }    from 'a-my-npms/my-chat/myChatButton';

export { default as ModalBox }      from 'a-my-npms/my-modal';

export { default as Myinput }       from 'a-my-npms/my-forms';
export { default as MyForm }        from 'a-my-npms/my-forms/myForm';

export { default as MyLoading }     from 'components/loading';
export { default as Header }        from 'components/Main/header';
export { default as Footer }        from 'components/Main/footer';
export { default as Login }         from 'components/Logged-out/login';
export { default as Register }      from 'components/Logged-out/register';
export { default as MainChat }      from 'components/chatHolders/mainPage';

export { default as Changelang }    from 'components/languages/changelang';
export { default as Languages }     from 'components/languages/languages';

// USER EXPORT DONE AND STYLE EXPORTS START

export { default as regisPStyle }   from 'styles/pages/regisPStyle.module.scss';
export { default as mainPStyle }    from 'styles/pages/mainPStyle.module.scss';

export { default as chatHoldersCss }    from 'styles/components/chatHolders.module.scss';
export { default as mainLoadingCss }    from 'styles/components/mainLoading.module.scss';
export { default as mainFootersCss }    from 'styles/components/mainFooters.module.scss';
export { default as mainHeadersCss }    from 'styles/components/mainHeaders.module.scss';
export { default as socialStyleCss }    from 'styles/components/socialStyle.module.scss';
export { default as regisCStyleCss }    from 'styles/components/regisCStyle.module.scss';
export { default as chatCoStyleCss }    from 'styles/components/chatComStyle.module.scss';

export { default as myFormMainCss }     from 'styles/components/myFormMain.module.scss';
export { default as myFormSelecCss }    from 'styles/components/myFormSelect.module.scss';
export { default as myFormSocalCss }    from 'styles/components/myFormSocial.module.scss';

export { default as myModalIconsCss }   from 'styles/components/myModalIcons.module.scss';
export { default as myModalModalCss }   from 'styles/components/myModalModal.module.scss';
export { default as myModalToastCss }   from 'styles/components/myModalToast.module.scss';

//IMAGES

export { default as myLogo }            from 'public/logos/logoShadowed.png';
export { default as myRegisterBackGround }            from 'public/images/background_regster.png';
ajsxfq5m

ajsxfq5m1#

如果您可以执行lazyloading,则可以使用它,但否则页面x的页面z、y、a、b的源代码也将被导入。

相关问题