Giter Club home page Giter Club logo

react-mobx-boot's Introduction

react-with-mobx-template

项目模版-react&&react-router@4&&mobx

技术选型

目录结构

├── src/
│   ├── components/     # 组件
│   ├── config/         # 一些配置项
│   ├── routes/         # 路由组件(页面维度)
│   ├── services/       # 数据接口
│   ├── stores/         # 数据模型
│   ├── utils/          # 工具
│   ├── app.js          # 入口文件
│   └── router.js       # 路由配置
├── webpack/            # webpack配置
├── index.html
├── package.json

在组件的设计上,应该明确componentsroutes目录中的组件职责:

  • 尽量保持components中的为纯组件(PureComponent),一般来说它所需要的数据都来源于页面组件或者父组件传给它的props
  • routes是页面维度的组件,它的职责是绑定相关联的stores数据,以数据容器的角色包含其它子组件。

接口服务都放在services中,供stores中的方法来调用。

使用

npm:
  npm install
  npm run dll
  npm run dev
  
yarn:
  yarn
  yarn dll
  yarn dev

在启动dev任务之前请务必先运行一次dll任务。该功能可以大大提升webpack打包性能,关于dll plugin的详细资料可查看 dll plugin

其他

  • 启用editorconfig来让编辑器自动读取格式化文件;启用eslint
  • 使用happypack加速打包。

关于项目的一些配置项

  • webpack的配置:
    • .babalrc中配置transform-decorators-legacy来使用修饰器;
    • webpack.config.js是基础配置,一般情况下不需要更改;
    • prod配置中,publicPath属性区分了测试和线上环境的静态资源引用路径,请按需替换;
    • dll配置用来生成一个单独的、平时不需要更改的vendor.min.js,在业务代码之前引入,只有在后续升级或者增删了主要依赖包才需要重新执行dll(大部分情况下后续更新的都是业务代码,更新依赖包的频次远远小于业务),这样一来只要这部分不发生改变,我们平时更新业务代码时这部分是不需要更迭版本的,利用原有缓存而不需要用户重新下载。

react-mobx-boot's People

Contributors

bingqichen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.