-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
104 lines (99 loc) · 2.98 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
module.exports = function(grunt) {
var path = require('path');
var pkg = grunt.file.readJSON('package.json');
// Project configuration.
grunt.initConfig({
pkg: pkg,
dom_munger: {
main: {
options: {
read: [
{selector:'link.dev',attribute:'href',writeto:'cssRefs',isPath:true},
{selector:'script.dev',attribute:'src',writeto:'jsRefs',isPath:true}
],
remove: ['.dev'],
append: [
{selector:'head',html:'<base href="//mapoflife.github.io/' + pkg.base + '/" />'},
{selector:'head',html:'<script>if (window.location.pathname.indexOf("EbbeNielsen") > 0){window.location.href = window.location.href.replace("EbbeNielsen", "indicators");}</script>'},
{selector:'head',html:'<link href="static/app.min.css" rel="stylesheet">'},
{selector:'head',html:'<script src="static/app.min.js"></script>'}
]
},
src: 'src/index.html',
dest: 'dist/index.html'
},
},
cssmin: {
main: {
src:'<%= dom_munger.data.cssRefs %>', //use our read css references and concat+min them
dest:'dist/static/app.min.css'
}
},
uglify: {
options: {mangle: false},
main: {
src: '<%= dom_munger.data.jsRefs %>', //use our read js references and concat+min them
dest:'dist/static/app.min.js'
}
},
copy : {
main: {
files: [
{ expand:true, nonull: false, cwd: 'src', src: ['static/app/**/*.{html,png,jpg,pdf}','static/*.{png,jpg}'], dest: 'dist/'}
],
},
},
watch: {
scripts: {
files: ['src/*'],
tasks: ['dom_munger','uglify','cssmin','copy'],
options: {
spawn: false,
},
}
},
buildcontrol: {
options: {
dir: 'dist',
commit: true,
branch: 'gh-pages',
push: true,
message: 'Built %sourceName% from commit %sourceCommit% on branch %sourceBranch%'
},
pages: {
options: {
remote: pkg.repository,
force:true,
branch: 'gh-pages'
}
}
},
express: {
dev: {
options: {
port: 9001,
bases: 'src',
server: path.resolve('./server/server')
}
}
},
open: {
server: {
url: 'http://localhost:<%= express.options.port %>'
}
}
});
grunt.loadNpmTasks('grunt-express');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-dom-munger');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-build-control');
grunt.loadNpmTasks('grunt-keepalive');
grunt.loadNpmTasks('grunt-open');
// Default task(s).
grunt.registerTask('build', ['dom_munger','uglify','cssmin','copy']);
grunt.registerTask('serve', ['express:dev', 'express-keepalive']);
grunt.registerTask('deploy', ['buildcontrol:pages']);
};