-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
124 lines (117 loc) · 3.11 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
module.exports = function (grunt) {
require('load-grunt-tasks')(grunt);
var testingPaths = ['./spec/**/*.js'];
var mochaCompilers = ['babel/register'];
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
env: {
grunt: {
NODE_ENV: 'grunt'
}
},
mochaTest: {
local: {
options: {
reporter: 'nyan',
require: mochaCompilers
},
src: testingPaths
}
},
eslint: {
target: ['./src/**/*.js', '!./src/components/common/**/*.js'],
// options: {
// configFile: './path/to/eslint.config.json'
// }
},
clean: {
package: {
src: ['./package']
}
},
copy: {
all: {
files: [
{ expand: true, cwd: './public/', src: ['**/*'], dest: './package/public/' },
// { expand: true, cwd: './server/', src: ['**/*'], dest: './package/server/' },
{ expand: true, cwd: './config/', src: ['**/*'], dest: './package/config/' },
{ expand: true, cwd: './views/', src: ['**/*'], dest: './package/views/' },
{ expand: false, src: ['./app.js'], dest: './package/app.js' },
{ expand: false, src: ['./package.json'], dest: './package/package.json' }
]
}
},
compress : {
main : {
options: {
mode: 'zip',
archive: function() {
var pkgJson = grunt.config.get('pkg');
return pkgJson.name + '-' + pkgJson.version + '.zip';
}
},
files : [
{ expand: true, src : ['**'], cwd : './package/' }
]
}
},
bump: {
options: {
commit: false,
commitMessage: 'v%VERSION%',
commitFiles: ['package.json', 'bower.json'],
createTag: true,
files: ['package.json', 'bower.json'],
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
push: false,
pushTo: 'origin',
tagMessage: 'v%VERSION%',
tagName: 'v%VERSION%',
updateConfigs: []
}
},
critical: {
test: {
options: {
base: './public/',
width: 2880,
height: 2880,
minify: true
},
src: 'views/critical.html',
dest: 'views/critical.css'
}
}
});
grunt.registerTask('webpack', 'Runs webpack', function (which) {
var done = this.async();
var webpack = require('webpack');
var config = require('./buildconfigs/' + which + '.config');
webpack(config, function (err, stats) {
if (stats.compilation.errors.length) {
var messages = ['\n'];
stats.compilation.errors.forEach(function(error) {
if (messages.indexOf(error.message) === -1) {
messages.push(error.message);
}
});
grunt.fail.warn(messages.join('\n'));
} else {
done();
}
});
});
grunt.registerTask('default', [
'env:grunt',
'webpack:dev'
]);
grunt.registerTask('test', [
'env:grunt'
]);
grunt.registerTask('build', [
'webpack:production',
'copy:all',
'compress:main',
'clean:package'
]);
};