-
Notifications
You must be signed in to change notification settings - Fork 18
/
Gruntfile.js
98 lines (90 loc) · 2.96 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
var pkg = require('./package.json');
module.exports = function (grunt) {
var exampleFile = grunt.option('src-file');
exampleFile = (!exampleFile)?'':exampleFile;
console.log('ex:'+exampleFile);
exampleFileDest = exampleFile.lastIndexOf('/')>-1?exampleFile.substring(exampleFile.lastIndexOf('/'), exampleFile.length):exampleFile;
console.log('ex:'+exampleFileDest);
grunt.initConfig({
watch: {
browserify: {
files: ['lib/**/*.js'],
tasks: ['browserify:lib']
},
example: {
files: [exampleFile],
tasks: ['browserify:example']
},
options: {
nospawn: true,
livereload: true
}
},
bower: {
install: {
options: {
targetDir: 'vendor',
cleanTargetDir: true,
cleanBowerDir: true
}
}
},
browserify: {
lib: {
src: pkg.componentJSX,
dest: './dist/'+pkg.componentJSX,
options: {
debug: true,
extensions: ['.js'],
transform: [
['babelify', {
loose: 'all'
}]
]
}
},
example: {
src: './example.js',
dest: './example/dist/example.js',
cwd: __dirname,
options: {
debug: true,
cwd: __dirname,
extensions: ['.js'],
transform: [
['babelify', {
loose: 'all'
}]
]
}
}
},
jscs: {
files: {
src: ['src/**/*.js']
},
options: {
config: '.jscsrc',
esprima: 'esprima-fb',
esnext: true
}
},
test: {
options: {
reporter: 'spec',
captureFile: pkg.testResultMain, // Optionally capture the reporter output to a file
quiet: false, // Optionally suppress output to standard out (defaults to false)
clearRequireCache: false // Optionally clear the require cache before running tests (defaults to false)
},
src: ['test/**/*.js']
}
});
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks("grunt-jscs");
grunt.loadNpmTasks('grunt-mocha-test');
grunt.loadNpmTasks('grunt-bower-task');
grunt.registerTask('default', ['bower', 'test', 'browserify:lib', 'watch']);
grunt.registerTask('build', ['bower', 'browserify:lib']);
grunt.registerTask('test', ['jscs']);
};