-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathGruntfile.js
118 lines (104 loc) · 3.59 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
module.exports = function(grunt) {
grunt.initConfig({
//package configuration by bower
pkg: grunt.file.readJSON('package.json'),
//clean task: empty the build/ folder
clean: ['build/'],
//copy task: copy needed files to the webserver directory
copy: {
main: {
files: [
{ expand: true, cwd: 'src/js/', src: '**/*.js', dest: 'build/js/' },
{ expand: true, flatten: true, src: 'src/**/*.css', dest: 'build/css/' },
{ expand: true, flatten: true, src: 'src/**/*.html', dest: 'build/' },
{ expand: true, src: 'assets/**/*', dest: 'build/' },
]
},
static: {
files: [
{ expand: true, cwd: 'src/static/', src: ['**/*.py', '!**/solution.py'], dest: 'build/static/' },
],
options: {
process: function(content, srcpath) {
// replace all tabs with 4 spaces
return content.replace(/\t/g, " ")
},
},
},
//skulpt js-python files
skulpt: {
files: [
{ expand: true, flatten: true, src: 'vendor/autonavx_skulpt/dist/{autonavx_skulpt,autonavx_skulpt.min,autonavx_skulpt-stdlib}.js', dest: 'build/js/' },
]
},
dependencies: {
files: [
{ expand: true, flatten: true, src: 'vendor/bootstrap/dist/css/*.min.css', dest: 'build/css/' },
{ expand: true, flatten: true, src: 'vendor/bootstrap/dist/fonts/*', dest: 'build/fonts/' },
{ expand: true, flatten: true, src: 'vendor/rickshaw/src/css/*.css', dest: 'build/css/' },
{ expand: true, flatten: true, src: 'vendor/rickshaw/examples/css/*.css', dest: 'build/css/' },
{ expand: true, flatten: true, src: 'vendor/bootstrap/js/button.js', dest: 'build/js/bootstrap/' },
{ expand: true, flatten: true, src: 'vendor/jquery/dist/jquery.min.js', dest: 'build/js/' },
{ expand: true, flatten: true, src: 'vendor/requirejs-text/text.js', dest: 'build/js/' },
{ expand: true, flatten: true, src: 'vendor/**/{require,domReady,three.min,d3,rickshaw.min,math.min}.js', dest: 'build/js/' },
{ expand: true, cwd: 'vendor/ace/lib/ace/', src: ['**/*.*', '!**/_test/*'], dest: 'build/js/ace/' },
]
}
},
//shell task: the invokation for rebuilding skulpt
shell: {
make_skulpt: {
options: {
stdout: true
},
command: 'make -C vendor/autonavx_skulpt all && make -C vendor/autonavx_skulpt release'
}
},
//watch task: rebuild and copy when files change
watch: {
framework: {
files: [ "src/**" ],
tasks: [ 'copy:main', 'copy:static' ]
},
skulpt: {
files: [ "vendor/autonavx_skulpt/src/**" ],
tasks: [ 'shell:make_skulpt', 'copy:skulpt' ]
},
},
//launch webserver with build/ as root dir
connect: {
server: {
options: {
base: 'build/'
}
}
},
//open the user's webbrowser
open: {
all: {
// Gets the port from the connect configuration
path: 'http://localhost:8000/test.html'
}
}
});
//activate grunt plugins handlers
grunt.loadNpmTasks('grunt-contrib-clean'); //for the cleaning
grunt.loadNpmTasks('grunt-contrib-watch'); //for the file change watching
grunt.loadNpmTasks('grunt-contrib-copy'); //for copying needed files
grunt.loadNpmTasks('grunt-shell'); //for rebuilding skulpt
//grunt.loadNpmTasks('grunt-bower-task');
grunt.loadNpmTasks('grunt-contrib-connect'); //for launching the webserver
grunt.loadNpmTasks('grunt-open'); //for launching the webbrowser
grunt.loadNpmTasks('grunt-contrib-requirejs');
//grunt will perform these actions in order
grunt_actions = [
'copy:main',
'copy:static',
'copy:skulpt',
'copy:dependencies',
'connect',
'open',
'watch'
]
grunt.registerTask('default', grunt_actions);
}