-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
264 lines (247 loc) · 8.14 KB
/
Gruntfile.js
File metadata and controls
264 lines (247 loc) · 8.14 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/*!
* RepRasp Party Like a Rockstar Gruntfile
* huement.com/reprasp
* @author Derek Scott
*/
/**
* Grunt Module
*/
module.exports = function (grunt) {
'use strict';
grunt.template.addDelimiters('handlebars-like-delimiters', '{{', '}}');
// Project configuration.
grunt.initConfig({
// Metadata.
pkg: grunt.file.readJSON('package.json'),
/**
* Project banner
*/
tag: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' License: <%= pkg.license.type %> */' + "\n",
bootbanner: "\n" + "/*! -- I Built This. Dont Hate. -- */" + "\n" + "\n" + "\n"
},
jqueryCheck: 'if (!jQuery) { throw new Error(\"HUI requires jQuery\") }\\n\\n',
// Task configuration.
clean: {
dist: ['cache']
},
/*
* Grunt Copy
* used for moving assests to dist
*/
copy: {
config: {
files: [
// includes files within path and its sub-directories
{expand: true, flatten: true, src: ['assets/files/**'], dest: 'www/webroot/files', filter: 'isFile'}
]
},
octoprint: {
files: [
// includes files within path and its sub-directories
{expand: true, flatten: true, src: ['www/webroot/css/**'], dest: 'octoprint_reprasp/static/css', filter: 'isFile'},
{expand: true, flatten: true, src: ['www/webroot/js/**'], dest: 'octoprint_reprasp/static/js', filter: 'isFile'},
{expand: true, flatten: true, src: ['www/webroot/files/**.png'], dest: 'octoprint_reprasp/static/img', filter: 'isFile'},
{expand: true, flatten: true, src: ['www/webroot/fonts/**'], dest: 'octoprint_reprasp/static/fonts', filter: 'isFile'},
{expand: true, flatten: true, src: ['www/webroot/status.html'], dest: 'octoprint_reprasp/static', filter: 'isFile'},
{expand: true, flatten: true, src: ['www/**.html'], dest: 'octoprint_reprasp/templates', filter: 'isFile'}
]
}
},
rename: {
dupit: {
src: 'octoprint_reprasp/templates/octoprint.html',
dest: 'octoprint_reprasp/templates/reprasp_ui_index.jinja2'
},
// Any number of targets here...
dupitcontrol: {
src: 'octoprint_reprasp/templates/control.html',
dest: 'octoprint_reprasp/templates/reprasp_ui_control.jinja2'
},
dupitstatus: {
src: 'octoprint_reprasp/templates/status.html',
dest: 'octoprint_reprasp/templates/reprasp_ui_status.jinja2'
},
dupitprint: {
src: 'octoprint_reprasp/templates/print.html',
dest: 'octoprint_reprasp/templates/reprasp_ui_print.jinja2'
},
dupitterminal: {
src: 'octoprint_reprasp/templates/terminal.html',
dest: 'octoprint_reprasp/templates/reprasp_ui_terminal.jinja2'
},
dupitsettings: {
src: 'octoprint_reprasp/templates/settings.html',
dest: 'octoprint_reprasp/templates/reprasp_ui_settings.jinja2'
},
nf3: {
src: 'octoprint_reprasp/static/js/RepRasp.js',
dest: 'octoprint_reprasp/static/js/reprasp-main.js'
}
},
/**
* Sass ( optional Compass )
*
* You can set the Compass Option to True. However you need Ruby-compass gems and other requirements.
* I was able to get it working w/ homebrew on my mac, but 13.10 ubuntu had issues
*
* It probably will work for you w/o it on. Its defaulted to off.
*
*/
sass: {
dev: {
options: {
style: 'expanded',
compass: false
},
files: {
'assets/stylesheets/hui_built.css': 'assets/stylesheets/hui.scss'
}
}
},
/*
* Minify CSS Files
*/
cssmin: {
minify: {
options: {
banner: '<%= pkg.name %>-<%= pkg.version %>',
},
files: {
'www/webroot/css/<%= pkg.name %>.min.css': ['assets/stylesheets/hui_built.css']
}
},
},
/*
* Combine Sass Files
*/
concat: {
options: {
banner: '<%= tag.banner %> <%= tag.bootbanner %>',
stripBanners: false
},
javascript: {
src: [
'assets/javascripts/actions.js', // command logic
'assets/javascripts/print_functions.js', // page specific functions
'assets/javascripts/docready.js' // setup each page and globals
],
dest: 'www/webroot/js/<%= pkg.name %>.js'
},
stylesheets: {
src: ['assets/stylesheets/hui_built.css'],
dest: 'www/webroot/css/<%= pkg.name %>.css',
},
},
/*
* Jade Templates
* Compile Jade Templates using package.json data
*
* Used for creating the documentation
*/
jade: {
compile: {
options: {
client: false,
pretty: true,
data: require('./package.json')
//,delimiters: 'handlebars-like-delimiters'
},
files: [ {
cwd: "jade",
src: ["**/index.jade", "**/status.jade", "**/print.jade", "**/control.jade", "**/terminal.jade", "**/settings.jade", "**/octoprint.jade"],
dest: "www",
expand: true,
ext: ".html",
rename: function () {
// use the source directory to create the file
// example with your directory structure
var Xdest = '', src = 'www/webroot/index.html/*';
return Xdest + src.substring(0, src.indexOf('/'));
}
} ]
}
},
/*
* Watch - not setup by default
*/
watch: {
sass: {
files: 'assets/stylesheets/{,*/}*.{scss,sass}',
tasks: ['sass', 'cssmin', 'concat:stylesheets']
},
jadedocs: {
files: 'jade/{,*/}*.{html,jade}',
tasks: ['jade']
},
js: {
files: 'assets/javascripts/{,*/}*.{js,json}',
tasks: ['concat:javascript', 'copy:config', 'uglify']
}
},
/*
* Minify Final Javascript Results
*/
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.homepage %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'www/webroot/js/<%= pkg.name %>.js',
dest: 'www/webroot/js/<%= pkg.name %>.min.js'
}
},
connect: {
server: {
options: {
port: 9001,
keepalive: true,
base: {
path: 'www',
options: {
index: 'index.html',
maxAge: 300000
}
}
}
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-recess');
grunt.loadNpmTasks('grunt-contrib-jade');
grunt.loadNpmTasks('grunt-template');
grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-rename');
/**
* Load Grunt plugins.
* call these from the command line, or just grunt for default.
*/
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.registerTask('default', ['reset','connect']);
// Command You run when you're editing the documentation
grunt.registerTask('dev', ['jade', 'watch']);
// Command You run when you're editing the documentation
grunt.registerTask('build', ['jade']);
grunt.registerTask('server', ['connect']);
//Style Sheets Only
grunt.registerTask('style', ['sass', 'cssmin', 'concat:stylesheets']);
//Builds for Octoprint Plugin
grunt.registerTask('octoprint', ['copy:octoprint', 'rename']);
//Cleans out cache, resets styles sheets
grunt.registerTask('reset', ['clean', 'copy', 'sass', 'concat', 'cssmin', 'uglify','jade']);
};