A single page react project template with antd.
react-spa-template
├── README.md
├── node_modules
├── package.json
├── .gitignore
├── .babelrc
├── .browserlistrc
├── .eslintrc
├── dist
│ ├── js
│ ├── index.html
│ └── stats.html
└── src
├── assets // static resource
|-- theme.less // antd theme file.
├── components // react components
├── containers // specify a container for every page
|-- AppContainer // handle menus. every page should be wrapped with AppContainer
├── core
|-- App.jsx // application's root element, bootstrap the application
├── redux // specify actions, reducers and action-constant
├── services // handle requests with server
├── routes // specify routes
|-- utils
|-- icons.js // @antd-desigin/icons. for performance.
└── templates
└── index.html // js resources will be injected to the html
git clone https://github.com/vivimee/react-spa-template.git my-app
cd my-app
yarn
yarn dev
- Add a container in /src/containers
- Import the container in /src/routes/index.js
- Specify a route
const Homepage = Loadable({
loader: () => import(/* webpackChunkName: "home-page" */'../containers/Homepage'),
});
<Route exact path="/" component={Homepage} />
If directly import antd/Icon, it will import @antd-design/icons/lib/dist, which make bundle size too large. So we can only import the Icons we used.
/* webapck.config.js */
resolve: {
alias: {
'@ant-design/icons/lib/dist$': path.resolve(PROJECT_ROOT, 'src', 'utils', 'icons.js'),
}
}
/* /src/utils/icons.js */
export {
default as CloseCircleOutline,
} from '@ant-design/icons/lib/outline/CloseCircleOutline';
yarn build
- update
/scripts/publish.js
yarn publish