forked from rtfeldman/seamless-immutable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
54 lines (48 loc) · 1.31 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var fs = require("fs");
var envify = require("envify/custom");
module.exports = function(grunt) {
grunt.initConfig({
mochaTest: {
test: {
src: ["test/*.spec.js"]
}
},
envify: {
dev: {
env: {
NODE_ENV: "development"
},
input: "src/seamless-immutable.js",
output: "seamless-immutable.development.js"
},
prod: {
env: {
NODE_ENV: "production"
},
input: "src/seamless-immutable.js",
output: "seamless-immutable.production.min.js"
}
},
uglify: {
prodMin: {
files: {
"seamless-immutable.production.min.js": ["seamless-immutable.production.min.js"]
}
}
}
});
grunt.loadNpmTasks("grunt-mocha-test");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.registerMultiTask("envify", "Envifies a source file to a target file", function() {
var inputStream = fs.createReadStream(this.data.input);
var outputStream = fs.createWriteStream(this.data.output);
var done = this.async();
inputStream
.pipe(envify(this.data.env)())
.pipe(outputStream)
.on("finish", done);
});
grunt.registerTask("test", "mochaTest");
grunt.registerTask("build", ["envify", "uglify"]);
grunt.registerTask("default", ["build", "test"]);
};