如何使用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构建的更多相关文章

  1. Grunt 构建SeaJS

    GitHub地址:https://github.com/MrLeo/SeaJS 目录结构 目录结构说明 web存放HTML文件 static存放所有HTML需要用到静态资源文件(css.js.img- ...

  2. Grunt构建工具能做哪些事?

    Grunt到底有什么作用?一般用来干嘛? 很多前端的工作,包括Less编译.javascript压缩.Css压缩等零零碎碎的工作, 都可以让Grunt来做. 实际上在项目开发中,一般是前端代码 与 后 ...

  3. 前端工程化系列[04]-Grunt构建工具的使用进阶

    在前端工程化系列[02]-Grunt构建工具的基本使用和前端工程化系列[03]-Grunt构建工具的运转机制这两篇文章中,我们对Grunt以及Grunt插件的使用已经有了初步的认识,并探讨了Grunt ...

  4. 前端工程化系列[03]-Grunt构建工具的运转机制

    在前端工程化系列[02]-Grunt构建工具的基本使用这篇文章中,已经对Grunt做了简单的介绍,此外,我们还知道了该如何来安装Grunt环境,以及使用一些常见的插件了,这篇文章主要介绍Grunt的核 ...

  5. 使用grunt构建前端项目

    1. grunt构建工具是基于nodejs上的,所以在使用之前一定要先安装好nodejs 2. 安装好nodejs后,node -v查看node版本 npm-v 查看npm版本信息 3. 在需要用到的 ...

  6. 使用grunt构建seajs项目

    1.安装nodejs 2.安装grunt-cli npm install -g grunt-cli 3.进入到项目目录,同时准备好package.json和Gruntfile.js文件 //packa ...

  7. 实战案例--Grunt构建Web程序

    GruntJS构建Web程序.使用Gruntjs来搭建一个前端项目,然后使用grunt合并,压缩JS文件,熟练了node.js安装和grunt.js安装后,接下来来实战一个案例,案例是根据snandy ...

  8. grunt 构建工具(build tool)初体验

    操作环境:win8 系统,建议使用 git bash (window下的命令行工具) 1,安装node.js 官网下载:https://nodejs.org/  直接点击install ,会根据你的操 ...

  9. Grunt构建工具插件篇——之less工具2

    Grunt任务分为两部分,一部分是任务,即Grunt要执行的代码,找到对应功能的插件就成.所以等会要下载grunt-contrib- less包,这个插件便是把less文件编译成能直接使用的css.另 ...

随机推荐

  1. mybatis根据property获取column

    mybatis根据property获取column mybatis根据类的属性获取xml文件中对应的column mybatis获取xml文件中property对应的column >>&g ...

  2. easyui-treegrid移除树节点出错

    easyui-treegrid移除树节点出错 >>>>>>>>>>>>>>>>>>>& ...

  3. Android 指定日期时间执行任务的Timer

    放上一个指定详细日期及时间的timer public class MainActivity extends Activity { private Handler handler = new Handl ...

  4. Python编写相关注意事项

    1.# -*- coding: utf-8 -*-代码首部添加这个,不然会报Non_ASCII charater错误 python闭包:实际应用场景1.保持闭包运行完后的环境: 2.根据外部作用域的局 ...

  5. Java文件操作二:File文件的方法

    一.文件的判断方法 判断方法 .boolean canExecute()判断文件是否可执行 .boolean canRead()判断文件是否可读 .boolean canWrite() 判断文件是否可 ...

  6. (四)值栈与OGNL

    所有的学习我们必须先搭建好Struts2的环境(1.导入对应的jar包,2.web.xml,3.struts.xml) 第一节:值栈简介 值栈是对应每个请求对象的一套内存数据的封装,Struts2 会 ...

  7. [LeetCode OJ] Decode Ways

    A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' - ...

  8. CoffeeScript飞一样的写javascript

    之前看到同事在使用coffeescript写js,当我看到那简介的coffee文件,就深深的被coffescript吸引了,简洁的语法,熟练之后会大大提升javascript的开发速度,写脚本也能像飞 ...

  9. js 的对象--如何定义一个对象

    通过var object={}  对象字面量,可以叫对象直接量来自定义一个对象 对象自面量是一个表达式,这个表达式的每次运算都创建并初始化一个新对象.每次计算对象字面量的时候,也都会计算他的每个属性值 ...

  10. Warning: Invalid argument supplied for foreach()

    经常对提交过来的数据进行双重循环,但是为空时会报错:Warning: Invalid argument supplied for foreach() 如下解决即可:foreach($data[$i]  ...