☀【SeaJS】SeaJS Grunt构建
如何使用Grunt构建一个中型项目?
https://github.com/twinstony/seajs-grunt-build
spmjs
http://docs.spmjs.org/doc/index
package.json
{
"name": "hi",
"version": "0.0.1",
"devDependencies": {
"grunt": "*",
"grunt-cmd-transport": "*",
"grunt-cmd-concat": "*",
"grunt-contrib-clean": "*"
}
}
Gruntfile.js
module.exports = function(grunt) {
grunt.initConfig({
transport: {
options: {
idleading: 'dist/'
},
target: {
expand: true,
cwd: '.',
src: ['module1.js', 'module2.js'],
dest: '.build'
}
},
concat: {
options: {
include: 'relative'
},
target: {
expand: true,
cwd: '.build',
src: ['*.js'],
dest: 'dist'
}
},
clean: {
build: ['.build']
}
});
grunt.loadNpmTasks('grunt-cmd-transport')
grunt.loadNpmTasks('grunt-cmd-concat')
grunt.loadNpmTasks('grunt-contrib-clean')
grunt.registerTask('build', ['transport', 'concat'/*, 'clean'*/])
}
module1.js
define(function(require, exports, module) {
var module1 = {}
module1.say = function(word) {
console.log(word)
}
module.exports = module1
})
module2.js
define(function(require, exports, module) {
var module1 = require('./module1')
module1.say('hi')
})
test.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<script src="sea.js"></script>
<script>
seajs.use('./dist/module2')
</script>
</body>
</html>
grunt build → dist/module2.js
define("dist/module2", [ "./module1" ], function(require, exports, module) { // 执行路径匹配的
var module1 = require("./module1");
module1.say("hi");
});
define("dist/module1", [], function(require, exports, module) {
var module1 = {};
module1.say = function(word) {
console.log(word);
};
module.exports = module1;
});
grunt-cmd-transport
spmjs / grunt-cmd-transport
https://github.com/spmjs/grunt-cmd-transport
grunt-cmd-concat
spmjs / grunt-cmd-concat
https://github.com/spmjs/grunt-cmd-concat

dynamic mappings

☀【SeaJS】SeaJS Grunt构建的更多相关文章
- Grunt 构建SeaJS
GitHub地址:https://github.com/MrLeo/SeaJS 目录结构 目录结构说明 web存放HTML文件 static存放所有HTML需要用到静态资源文件(css.js.img- ...
- Grunt构建工具能做哪些事?
Grunt到底有什么作用?一般用来干嘛? 很多前端的工作,包括Less编译.javascript压缩.Css压缩等零零碎碎的工作, 都可以让Grunt来做. 实际上在项目开发中,一般是前端代码 与 后 ...
- 前端工程化系列[04]-Grunt构建工具的使用进阶
在前端工程化系列[02]-Grunt构建工具的基本使用和前端工程化系列[03]-Grunt构建工具的运转机制这两篇文章中,我们对Grunt以及Grunt插件的使用已经有了初步的认识,并探讨了Grunt ...
- 前端工程化系列[03]-Grunt构建工具的运转机制
在前端工程化系列[02]-Grunt构建工具的基本使用这篇文章中,已经对Grunt做了简单的介绍,此外,我们还知道了该如何来安装Grunt环境,以及使用一些常见的插件了,这篇文章主要介绍Grunt的核 ...
- 使用grunt构建前端项目
1. grunt构建工具是基于nodejs上的,所以在使用之前一定要先安装好nodejs 2. 安装好nodejs后,node -v查看node版本 npm-v 查看npm版本信息 3. 在需要用到的 ...
- 使用grunt构建seajs项目
1.安装nodejs 2.安装grunt-cli npm install -g grunt-cli 3.进入到项目目录,同时准备好package.json和Gruntfile.js文件 //packa ...
- 实战案例--Grunt构建Web程序
GruntJS构建Web程序.使用Gruntjs来搭建一个前端项目,然后使用grunt合并,压缩JS文件,熟练了node.js安装和grunt.js安装后,接下来来实战一个案例,案例是根据snandy ...
- grunt 构建工具(build tool)初体验
操作环境:win8 系统,建议使用 git bash (window下的命令行工具) 1,安装node.js 官网下载:https://nodejs.org/ 直接点击install ,会根据你的操 ...
- Grunt构建工具插件篇——之less工具2
Grunt任务分为两部分,一部分是任务,即Grunt要执行的代码,找到对应功能的插件就成.所以等会要下载grunt-contrib- less包,这个插件便是把less文件编译成能直接使用的css.另 ...
随机推荐
- 微信上传图文消息素材40007,invalid media_id hint
上传图文消息素材40007,invalid media_id hint,微信40007 >>>>>>>>>>>>>> ...
- 第一篇:APUE-操作系统IO模型
操作系统IO模型 操作系统IO模型 声明:如下内容是根据APUE和mycat两本著作中关于I/O模式的一些内容加上自己的一些理解整理而成,仅供学习使用. 本节内容 UNIX下可用的五种I/O模型 ...
- javascript异步加载详解(转)
本文总结一下浏览器在 javascript 的加载方式. 关键词:异步加载(async loading),延迟加载(lazy loading),延迟执行(lazy execution),async 属 ...
- linux下查找文件
1,find 经常在linux下工作,总要查找一些文件,于是就搜索的学习了一下 find 指定目录 指定条件 指定动作 举例:find . -name "my*" 查找 当前目录下 ...
- [Cache] C#操作缓存--CacheHelper缓存帮助类 (转载)
点击下载 CacheHelper.zip CacheHelper 缓存帮助类 C#怎么操作缓存 怎么设置和取缓存数据,都在这个类里面呢 下面看一下代码吧 /// <summary> /// ...
- google map 定位
在map初始化的过程中,得到当前经纬度,完成初始化地图,通过HTML5中的Geolocation实现,具体参考:http://www.jb51.net/html5/71556.html 1.获取当前地 ...
- ios 添加通用断点定位到异常点
今天下午项目突然异常崩溃,因为代码没有多少结构改动,恢复旧版本还是不行,判定为网络获取信息异常,无奈从网络获取的信息太多,搞了很久后发现有个通用异常断点很好用,新手就是新手,浪费时间了.
- oc 获取当前时间
//获取当前日期 NSDate* date = [NSDate date]; NSDateFormatter* dateFormat = [[NSDateFormatter alloc] init]; ...
- O-C相关-03:面向对象概念的具体介绍
1.面向对象的概念 面向对象(object-oriented ;简称: OO) 至今还没有统一的概念,我这里把它定义为:按人们认识客观世界的系统思维方式,采用基于对象(实体)的概念建立模型,模拟客观世 ...
- cocos2d-x系列 Mac下配置cocos2d-x开发环境(android和ios)
一.下载cocos2d-x http://cocos2d-x.org/projects/cocos2d-x/wiki/Download cocos2d-x-2.1.4.zip @ June.18, 2 ...