-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
193 lines (173 loc) · 4.76 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
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
const sass = require('node-sass');
var tsConfig = require('./tsconfig.json').compilerOptions;
tsConfig.references = ['node_modules/**/*.d.ts', 'typings/**/*.d.ts'];
module.exports = function (grunt) {
var appConfig = grunt.file.readJSON('package.json');
// Load grunt tasks automatically
// see: https://github.com/sindresorhus/load-grunt-tasks
require('load-grunt-tasks')(grunt);
// Time how long tasks take. Can help when optimizing build times
// see: https://npmjs.org/package/time-grunt
require('time-grunt')(grunt);
var pathsConfig = function (appName) {
this.app = appName || appConfig.name;
return {
app: this.app,
templates: this.app + '/templates',
css: this.app + '/static/css',
sass: this.app + '/static/sass',
fonts: this.app + '/static/fonts',
images: this.app + '/static/images',
ts: this.app + '/static/ts',
js: this.app + '/static/js',
js_template: this.app + '/static/template/velo-2016/html/js',
sass_template: this.app + '/static/template/velo-2016/html/css',
manageScript: 'manage.py'
}
};
grunt.initConfig({
paths: pathsConfig(),
pkg: appConfig,
// see: https://github.com/gruntjs/grunt-contrib-watch
watch: {
gruntfile: {
files: ['Gruntfile.js']
},
sass: {
files: ['<%= paths.sass %>/**/*.{scss,sass}', '<%= paths.sass_template %>/**/*.{scss,sass}'],
tasks: ['sass:dev'],
options: {
atBegin: true,
implementation: sass,
}
},
concat: {
files: ['<%= paths.js_template %>/**/*.js', '<%= paths.js %>/components/*.js', '<%= paths.js %>/../coffee/*.js'],
tasks: ['concat:dist'],
options: {
atBegin: true
}
},
livereload: {
files: [
'<%= paths.js %>/**/*.js',
'<%= paths.sass %>/**/*.{scss,sass}',
'<%= paths.app %>/**/*.html'
],
options: {
spawn: false,
livereload: true
}
}
},
concat: {
dist: {
src: [
'<%= this.app %>/static/vendor/bower_components/devbridge-autocomplete/dist/jquery.autocomplete.js',
'<%= paths.js_template %>/libs/*.js',
'<%= paths.js_template %>/utilities/*.js',
'<%= paths.js_template %>/components/*.js',
'<%= paths.js %>/components/*.js',
'<%= paths.js %>/../coffee/*.js'
],
dest: '<%= paths.js %>/project.js'
}
},
uglify: {
options: {
mangle: false,
screwIE8: true,
sourceMap: true
},
project: {
files: {
'<%= paths.js %>/project.min.js': ['<%= paths.js %>/project.js']
}
}
},
sass: {
dev: {
options: {
outputStyle: 'nested',
sourceMap: false,
precision: 10,
implementation: sass
},
files: {
'<%= paths.css %>/main/project.css': '<%= paths.sass %>/project.scss'
},
},
dist: {
options: {
outputStyle: 'compressed',
sourceMap: false,
precision: 10,
implementation: sass
},
files: {
'<%= paths.css %>/main/project.min.css': '<%= paths.sass %>/project.scss'
},
}
},
//see https://github.com/nDmitry/grunt-postcss
postcss: {
options: {
map: true, // inline sourcemaps
processors: [
require('pixrem')(), // add fallbacks for rem units
require('autoprefixer-core')({browsers: [
'Android 2.3',
'Android >= 4',
'Chrome >= 20',
'Firefox >= 24',
'Explorer >= 8',
'iOS >= 6',
'Opera >= 12',
'Safari >= 6'
]}), // add vendor prefixes
require('cssnano')() // minify the result
]
},
dist: {
src: '<%= paths.css %>/*.css'
}
},
docker_io: {
dist: {
options: {
dockerFileLocation: '.',
buildName: 'project_velo',
tag: 'latest',
username: 'ameriks',
push: true,
force: true
}
}
},
// see: https://npmjs.org/package/grunt-bg-shell
bgShell: {
_defaults: {
bg: false
},
runDjango: {
cmd: 'python <%= paths.manageScript %> runserver'
},
devDocker: {
cmd: 'docker-compose -f dev.yml build django'
}
}
});
grunt.registerTask('serve', [
'bgShell:runDjango',
'watch'
]);
grunt.registerTask('build', [
'sass:dist',
'postcss',
'concat:dist',
'uglify:project'
]);
grunt.registerTask('default', [
'build'
]);
};