forked from esfiddle/esfiddle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
140 lines (137 loc) · 3.63 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
/* eslint-disable */
module.exports = (grunt) => {
require('load-grunt-tasks')(grunt);
const jsSrcFiles = [
'src/js/**/*.js',
'!src/js/authenticated.js'
],
htmlFiles = ['src/views/index.html', 'src/views/about.html']
jsFiles = 'src/**/*.js',
styleFiles = ['dist/lib/**/*.css', 'style/**/*.less'],
pkg = grunt.file.readJSON('package.json'),
npmTasks = [
'grunt-contrib-uglify',
'grunt-contrib-watch',
'grunt-jscs',
'grunt-contrib-imagemin',
'grunt-inline',
'grunt-browser-sync',
'grunt-express-server',
'grunt-githooks',
'grunt-browserify',
];
grunt.initConfig({
pkg,
githooks: {
all: {
'pre-push': 'test',
},
},
browserify: {
prod: {
src: ['src/js/examples/*.js', 'src/js/index.js'],
dest: 'dist/src/es6-fiddle.js',
options: {
browserifyOptions: { debug: true },
transform: [['babelify', { presets: ['es2015'] }]],
},
},
},
uglify: {
compile: {
files: {
'dist/src/authenticated.js': ['src/js/authenticated.js'],
'dist/lib/babel/babel.min.js': ['dist/lib/babel/*.js', '!dist/lib/babel/babel.min.js'],
},
},
},
less: {
production: {
files: {
'dist/style/es6-fiddle.css': ['dist/lib/**/*.css', 'style/main.less'],
'dist/style/profile.css': ['style/profile.less'],
'dist/style/blog.css': ['style/blog.less'],
'dist/style/about.css': ['style/about.less'],
},
},
},
watch: {
options: {
reload: true,
},
style: {
files: styleFiles,
tasks: ['less', 'inline'],
},
src: {
files: jsFiles,
tasks: ['browserify', 'uglify', 'eslint'],
},
html: {
files: htmlFiles,
tasks: ['inline'],
},
},
imagemin: {
dynamic: {
files: [{
expand: true,
src: ['**/*.{png,jpg,gif}'],
}],
},
},
inline: {
index: {
src: 'src/views/index.html',
dest: 'dist/index.html',
},
about: {
src: 'src/views/about.html',
dest: 'dist/about.html',
},
},
eslint: {
options: {
config: '.eslintrc',
},
target: ['src/**/*.js', 'Gruntfile.js'],
},
lesslint: {
options: {
imports: ['style/**/*.less'],
csslint: {
'box-sizing': false,
'adjoining-classes': false,
'universal-selector': false,
'font-sizes': false,
'box-model': false,
'unique-headings': false,
},
failOnWarning: false,
},
target: ['style/main.less'],
},
browserSync: {
bsFiles: {
src: [jsSrcFiles, styleFiles],
},
options: {
watchTask: true,
proxy: 'http://localhost:3000',
reloadOnRestart: true,
},
},
express: {
dev: {
options: {
script: 'server/app.js',
},
},
},
});
npmTasks.forEach(task => grunt.loadNpmTasks(task));
grunt.registerTask('default', ['githooks', 'watch']);
grunt.registerTask('test', ['lesslint', 'eslint']);
grunt.registerTask('build', ['less', 'browserify', 'uglify', 'imagemin', 'inline']);
grunt.registerTask('dev', ['less', 'express:dev', 'browserSync', 'watch']);
};