9 Star 0 Fork 0

好大棵葱吖 / restack-mobile-gitbook

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CONFIG_INTRO.md 2.36 KB
一键复制 编辑 原始数据 按行查看 历史
hibad1 提交于 2017-01-03 11:18 . 修改文件名

项目配置

config目录主要用于SDK脚手架打包/运行的配置.

####项目配置说明 config文件主要描述了框架的基本信息以及主要构成

title为框架的名称

staticUrl是指外链webpack-dev-server 服务的url配置,非isomorphic模式置空字段

title: "Appbricks",
staticUrl: ""

routes描述了后台如何匹配url, 可参考express中间件路由配置: http://expressjs.com/zh-cn/guide/using-middleware.html

  routes: {
    '/*': {
      view: 'index',
      scripts: ['vendors', 'index'],
      csses:['vendors']
    }
  },

控制是否开启后端渲染模式. (暂未开放)

isomorphic:false

entries描述前端有多少个entry, 入口为webpack进行bundle的模块入口, 一个entries对应一个独立的bundle.详情请参考webpack1配置文档entry部分: http://webpack.github.io/docs/multiple-entry-points.html

  entries: {
    'index': `./src/js/app/index.jsx`,
  }

proxy遵循http-proxy-middleware协议

http-proxy-middleware 是一套 Node.js 代理中间件

api是前端的路径,当要跳转到该路径时,会自动转到该代理

proxy:[
  {
    api: '/baseurl',
    target: 'http://localhost:8080'
  },
  {
    api: '/:module/api',
    target: 'http://localhost:8081'
  }
]

总体配置

const development = {

  title: "Appbricks",

  staticUrl: "",

  languages: ['zh-cn', 'en'],

  // 描述后端是如何匹配URL,以及hbs模板
  routes: {
    '/*': {
      view: 'index',
      scripts: ['vendors', 'index'],
      csses:['vendors']
    }
  },
  isomorphic: false,
  // 描述前端有多少个entry
  entries: {
    'index': `./src/js/app/index.jsx`,
  }

}

module.exports = development

####配置文件名规则 使用SDK时会使用config目录下的配置

生产模式运行环境以及生产包构建 会读取 prod.js 中的信息, 请保证config目录下 prod.js 生产配置正确.

开发模式下可以根据需要自行创建配置文件, 运行restack-mobile指令时可以通过添加参数-e去设定读取的配置文件,例如:

config目录下新建,并填写好配置文件 dev1.js

命令行输入

restack-mobile run -e dev1

SDK跑起server时会读取dev1配置

运行 restack-mobile run 默认使用config/dev.js配置 运行生产调试模式请使用 restack-mobile run -e prod ,此时会读取 prod.js 的配置.

JavaScript
1
https://gitee.com/onion_stu/restack-mobile-gitbook.git
git@gitee.com:onion_stu/restack-mobile-gitbook.git
onion_stu
restack-mobile-gitbook
restack-mobile-gitbook
master

搜索帮助