forked from wix-incubator/react-templates
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
120 lines (114 loc) · 3.75 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
clean: {
main: {
src: ['coverage', 'playground/**/*.rt.js']
}
},
eslint: {
all: {
src: [
'src/**/*.js', 'playground/**/*.js',
'test/src/**/*.js',
'!playground/libs/**/*.js',
'!playground/dist/**/*.js',
'!playground/**/*.rt.js'
]
}
},
jasmine_node: {
options: {
forceExit: true,
match: '.',
matchall: false,
specNameMatcher: 'spec',
extensions: 'js'
},
all: ['server/test'],
grunt: ['conf/tasks/test']
},
browserify: {
rt: {
files: {
'playground/dist/rt-main.browser.js': ['playground/rt-main.js']
},
options: {
transform: ['brfs'],
alias: ['react:react/addons']
}
}
},
tape: {
options: {
pretty: true,
output: 'console'
},
files: ['test/src/*.js']
},
watch: {
rt: {
files: [
'playground/*.rt'
],
tasks: ['rt'],
options: {
spawn: false
}
},
test: {
files: [
'src/**/*.*', 'test/**/*.*'
],
tasks: ['test'],
options: {
spawn: false
}
}
},
uglify: {
my_target: {
//options: {
// sourceMap: true,
// sourceMapIncludeSources: true,
// sourceMapIn: 'example/coffeescript-sourcemap.js', // input sourcemap from a previous compilation
//},
files: {
'playground/dist/rt-main.browser.min.js': ['playground/dist/rt-main.browser.js'],
'playground/libs/requirejs-plugins/text.min.js': ['playground/libs/requirejs-plugins/text.js'],
'playground/libs/requirejs-plugins/json.min.js': ['playground/libs/requirejs-plugins/json.js']
}
}
},
requirejs: {
compile: {
options: readConfig('./home.config.js')
},
playground: {
options: readConfig('./playground.config.js')
}
}
});
function readConfig(file) {
return eval(require('fs').readFileSync(file).toString()); // eslint-disable-line no-eval
}
grunt.loadNpmTasks('grunt-tape');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.registerTask('default', ['eslint:all']);
grunt.registerTask('lint', ['eslint:all']);
grunt.registerTask('test', ['tape']);
grunt.registerTask('rt', () => {
const reactTemplates = require('./src/cli');
const files = grunt.file.expand('playground/*.rt');
const ret = reactTemplates.execute({modules: 'amd', force: true, _: files});
return ret === 0;
});
grunt.registerTask('build', ['rt', 'browserify:pg']);
grunt.registerTask('home', ['rt', 'browserify:home']);
grunt.registerTask('pgall', ['rt', 'browserify', 'uglify', 'requirejs']);
grunt.registerTask('all', ['default', 'test']);
};