ITeye博客

开发meteor的Smart package(智能包)过程

weiyongqing · 2012-12-25 00:26 · meteorjs · Web前端 · meteor · Markdown

meteor的SmartPackage方式带来开发的方便,这里介绍的是关于https://atmosphere.meteor.com/的智能包开发。具体开发过程介绍为https://atmosphere.meteor.com/wtf/package 下边是我做测试的流程 1、新建文件夹:meteor-package-make,文件夹下建hello.js,smart.json,package.js 2、smart.json内容为:

{
  "name": "demo-pkg",
  "description": "智能包测试",
  "homepage": "",
  "author": "魏永清",
  "version": "0.1.0",
  "git": "",
  "packages": {}
}

package.js内容为:

Package.describe({
  summary: "我的分模块开发智能包测试"
});

Package.on_use(function (api, where) {
  api.add_files('hello.js', 'client');
});

hello.js只是简单控制台打印,

function sayWei(){console.log('this is weiyongqing,研究群:256195986,')};

但在实际开发中应该使用闭包进行代码隔离,这些可以看一下https://atmosphere.meteor.com网站上的库代码 好,ok,本地开发就这么简单,然后下一步怎样加到一个meteor项目中去 1、新建一meteor项目,注意用mrt命令 mrt create demo-smart cd demo-smart 2、修改smart.json文件,添加上边建立的包,

{
  "meteor": {
    "git": "https://github.com/meteor/meteor.git",
    "branch": "master"
  },
  "packages": {
      "package-make" : {
      "path": "/media/main/weiyongqing/project/meteor-package-make"
      }
  }

3、运行: mrt add package-make mrt 启动服务 4、在google浏览器输入localhost:3000,按F12键,可在浏览器控制台下看到打印hell.js程序中文字 实验完毕。 只是一个简单示例,复杂的参考https://atmosphere.meteor.com上的库

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。