This is a simple (admin) starter with typescript, react and webpack.
Have a quick view:
$ npm i
$ npm run dev
$ npm run qa/prod
We do not use any mock tools(Anyway, you can use the data format from server response to achieve it!), all data interaction depends on a real node service with nest and mongodb. Integration is in our future plan! We will make sure that you still can fully separate client and server side. 😁😁😁
- webpack-4.x
- typescript-3.0.x
- react-16.4.x
- mobx-5.x (5.x makes your application must be running in the browser that support es2015+, if you are not willing, you can use 4.x)
- react-router-4
- mobx-react-router
- component hot reload
- use ant design as UI framework
- import svg icon as a component by
@svgr/webpack
, there is an example in the doc of steamer-react-redux-ts - async to load component by
react-loadable
- import .(s)css auto generate .(s)css.d.ts by
typings-for-css-modules-loader
- create component folder by
customaddcomponents
which is added to npm scriptnpm run add
- config menu by user with permission
import * as React from 'react'
import { inject, observer } from 'mobx-react'
import { Button } from 'antd'
interface IStoreProps {
routerStore?: RouterStore;
}
function Test({ routerStore }: IStoreProps) {
const gotoHome = () => {
routerStore.push('/')
}
return (
<Button type="primary" onClick={gotoHome}>
go to page index directly
</Button>
)
}
export default inject(
(store: IStore): IStoreProps => ({
routerStore: store.routerStore
})
)(observer(Login))
import * as React from 'react'
import Loadable from 'react-loadable'
import { HashRouter as Router, Switch, Route } from 'react-router-dom'
import PageLoading from '@components/PageLoading'
const Test = Loadable({
loader: () => import(/* webpackChunkName: "test" */ './Test'),
loading: PageLoading
})
const AppRouter = () => (
<Router>
<Switch>
<Route exact path="/test" component={Test} />
</Switch>
</Router>
)
export default AppRouter
server {
listen 9993;
server_name localhost:9993;
location / {
root ~/Documents/react/ts-react-webpack4/dist/qa/;
index index.html index.htm;
}
}