{"action":"created","issue":{"url":"https://api.github.com/repos/seajs/seajs/issues/538","labels_url":"https://api.github.com/repos/seajs/seajs/issues/538/labels{/name}","comments_url":"https://api.github.com/repos/seajs/seajs/issues/538/comments","events_url":"https://api.github.com/repos/seajs/seajs/issues/538/events","html_url":"https://github.com/seajs/seajs/issues/538","id":10938724,"number":538,"title":"构建工具","user":{"login":"lifesinger","id":97227,"avatar_url":"https://avatars.githubusercontent.com/u/97227?v=3","gravatar_id":"","url":"https://api.github.com/users/lifesinger","html_url":"https://github.com/lifesinger","followers_url":"https://api.github.com/users/lifesinger/followers","following_url":"https://api.github.com/users/lifesinger/following{/other_user}","gists_url":"https://api.github.com/users/lifesinger/gists{/gist_id}","starred_url":"https://api.github.com/users/lifesinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifesinger/subscriptions","organizations_url":"https://api.github.com/users/lifesinger/orgs","repos_url":"https://api.github.com/users/lifesinger/repos","events_url":"https://api.github.com/users/lifesinger/events{/privacy}","received_events_url":"https://api.github.com/users/lifesinger/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/seajs/seajs/labels/documentation","name":"documentation","color":"444444"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/seajs/seajs/milestones/12","labels_url":"https://api.github.com/repos/seajs/seajs/milestones/12/labels","id":368419,"number":12,"title":"2.1.1","description":"","creator":{"login":"lifesinger","id":97227,"avatar_url":"https://avatars.githubusercontent.com/u/97227?v=3","gravatar_id":"","url":"https://api.github.com/users/lifesinger","html_url":"https://github.com/lifesinger","followers_url":"https://api.github.com/users/lifesinger/followers","following_url":"https://api.github.com/users/lifesinger/following{/other_user}","gists_url":"https://api.github.com/users/lifesinger/gists{/gist_id}","starred_url":"https://api.github.com/users/lifesinger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifesinger/subscriptions","organizations_url":"https://api.github.com/users/lifesinger/orgs","repos_url":"https://api.github.com/users/lifesinger/repos","events_url":"https://api.github.com/users/lifesinger/events{/privacy}","received_events_url":"https://api.github.com/users/lifesinger/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":10,"state":"closed","created_at":"2013-07-01T23:14:04Z","updated_at":"2013-07-19T00:59:34Z","due_on":"2013-07-31T07:00:00Z","closed_at":"2013-07-18T01:01:00Z"},"comments":73,"created_at":"2013-02-13T02:45:36Z","updated_at":"2015-01-29T12:24:50Z","closed_at":"2013-04-01T12:19:37Z","body":"## 标准构建\r\n\r\n> spm3 已经发布，建议使用最新的构建工具。http://spmjs.io/documentation/develop-a-package#build\r\n\r\n---\r\n\r\n如果项目遵循推荐的标准目录结构：\r\n\r\n```\r\nfoo-module/\r\n  |-- dist                    存放构建好的文件\r\n  |-- src                     存放 js、css 等源码\r\n  |     |-- foo.js\r\n  |     `-- style.css\r\n  `-- package.json      模块信息   \r\n```\r\n\r\n那么构建很简单。首先安装 spm 工具（spm2）：\r\n\r\n```\r\n$ npm install spm@2.x -g\r\n$ npm install spm-build@0.x -g\r\n```\r\n\r\n然后运行构建命令：\r\n\r\n```\r\n$ cd foo-module\r\n$ spm build\r\n```\r\n\r\n这样，就会根据 `package.json` 中的信息，将文件自动构建到 `dist` 目录下。构建后，还需要将 dist 目录下的文件部署到 `sea-modules` 目录中，比如 examples 中的 `make deploy` 命令：[Makefile](https://github.com/seajs/examples/blob/master/static/hello/Makefile)\r\n\r\n详细可参考 <http://docs.spmjs.org/>\r\n\r\n推荐将 [seajs/examples](https://github.com/seajs/examples) clone 到本地，实际操作一下就清楚。\r\n\r\n\r\n\r\n## 自定义构建\r\n\r\n如果标准构建无法满足需求，可以直接使用 Grunt 来完成。Grunt 是一个非常优秀的构建工具，详见：http://gruntjs.com/\r\n\r\n利用 Grunt 来构建 CMD 模块需要使用到以下 Grunt Tasks：\r\n\r\n- [grunt-cmd-transport](https://github.com/spmjs/grunt-cmd-transport)\r\n- [grunt-cmd-concat](https://github.com/spmjs/grunt-cmd-concat)\r\n\r\n这一块真的很简单，只要你熟悉 Grunt，因此先阅读 Grunt 的文档吧，然后有任何问题，欢迎回复。\r\n\r\n推荐几篇社区贡献的文章：\r\n\r\n- [CMD 模块构建，从认识 Grunt 开始](https://github.com/seajs/seajs/issues/670)\r\n- [如何使用 Grunt 构建一个中型项目](https://github.com/seajs/seajs/issues/672)\r\n- [使用 spm 构建业务模块的个人经验](https://github.com/seajs/seajs/issues/690)\r\n\r\n非常欢迎大家的使用经验总结。\r\n\r\n\r\n---\r\n\r\n有任何问题，欢迎留言交流。\r\n注意：已解决的问题，会在整理后删除掉。\r\n"},"comment":{"url":"https://api.github.com/repos/seajs/seajs/issues/comments/72015924","html_url":"https://github.com/seajs/seajs/issues/538#issuecomment-72015924","issue_url":"https://api.github.com/repos/seajs/seajs/issues/538","id":72015924,"user":{"login":"afc163","id":507615,"avatar_url":"https://avatars.githubusercontent.com/u/507615?v=3","gravatar_id":"","url":"https://api.github.com/users/afc163","html_url":"https://github.com/afc163","followers_url":"https://api.github.com/users/afc163/followers","following_url":"https://api.github.com/users/afc163/following{/other_user}","gists_url":"https://api.github.com/users/afc163/gists{/gist_id}","starred_url":"https://api.github.com/users/afc163/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/afc163/subscriptions","organizations_url":"https://api.github.com/users/afc163/orgs","repos_url":"https://api.github.com/users/afc163/repos","events_url":"https://api.github.com/users/afc163/events{/privacy}","received_events_url":"https://api.github.com/users/afc163/received_events","type":"User","site_admin":false},"created_at":"2015-01-29T12:24:50Z","updated_at":"2015-01-29T12:24:50Z","body":"https://github.com/spmjs/spm/wiki/%E8%B0%83%E8%AF%95-CommonJS-%E6%BA%90%E7%A0%81"}}