-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
109 lines (86 loc) · 2.82 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
meta: {
site_name: 'Belk Building Supply, LLC',
build_date: '<%= grunt.template.today("yyyymmddHHMM") %>',
version_string: '<=% pkg.version %>-<%= meta.build_date %>'
},
env: {},
buildTemplates: {
options: grunt.file.readJSON('etc/tmpl_config.json')
},
testServer: {
options: grunt.file.readJSON("etc/test_server.json")
},
concat: {
options: {
sourceMap: true,
process: true
},
site: {
src: ['src/site/site.js'],
dest: 'www/js/site.js'
},
utils: {
src: ['src/utils/turbo.js', 'src/utils/tabular.js'],
dest: 'www/js/utils.js'
}
},
copy: {
js: {
expand: true,
cwd: 'src/pages/',
src: ['*'],
dest: 'www/js/'
},
assets: {
expand: true,
cwd: 'assets/',
src: ['**'],
dest: 'www/'
}
}
});
grunt.config.merge({
buildTemplates: {
options: { }
}
});
/*================================
Register Plugins
================================*/
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadTasks('./src/grunt');
/*================================
Target & Target Settings
================================*/
let target = grunt.option('target') || 'dev';
if(target != 'dev') grunt.config.merge(grunt.file.readJSON(`etc/${target}.json`));
/*================================
Basic Tasks
================================*/
const Tasks = {
default: ['jsbuild', 'templates', 'copy:assets'],
templates: ['buildTemplates'],
jsbuild: ['concat:site', 'concat:utils', 'copy:js'],
deploy: (target != 'dev') ? ['default','stage'] : ['default'],
test: ['default','testServer']
};
Object.keys(Tasks).map( k => grunt.registerTask(k, Tasks[k]) );
grunt.registerTask("stage", "Deploy to GitHub.", function() {
let done = this.async();
//grunt.file.copy("www", grunt.config.get('env.deploy'));
let ghp = require('gh-pages');
ghp.publish('www', {
branch: 'gh-pages',
repo: 'https://github.com/monroe-hardware/bbs_2023.git'
}, (err) => {
if(err) console.log(err);
else done();
});
});
}