-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
163 lines (150 loc) · 4.16 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
module.exports = function(grunt) {
"use strict";
require('time-grunt')(grunt);
var global_vars = {
theme_dist_css: 'dist/css',
theme_dist_js: 'dist/js',
theme_src_scss: 'src/scss',
theme_src_js: 'src/js',
};
grunt.initConfig({
global_vars: global_vars,
pkg: grunt.file.readJSON('package.json'),
sass_globbing: {
dist: {
files: {
'<%= global_vars.theme_src_scss %>/_init.scss': [
'<%= global_vars.theme_src_scss %>/presentation/_functions.scss',
'<%= global_vars.theme_src_scss %>/presentation/_variables.scss',
'<%= global_vars.theme_src_scss %>/presentation/_mixins.scss',
],
'<%= global_vars.theme_src_scss %>/_base.scss': [
'<%= global_vars.theme_src_scss %>/component/**/*.scss',
'<%= global_vars.theme_src_scss %>/jquery-ui/**/*.scss',
'<%= global_vars.theme_src_scss %>/modules/**/*.scss',
'<%= global_vars.theme_src_scss %>/paragraphs/**/*.scss',
'<%= global_vars.theme_src_scss %>/layouts/**/*.scss',
'<%= global_vars.theme_src_scss %>/_overrides.scss'
]
}
}
},
sass: {
modules: {
options: {
includePaths: [
'scss'
],
outputStyle: 'nested',
sourceMap: true
}
},
dist: {
options: {
includePaths: [
'node_modules/bootstrap/scss/',
'node_modules/breakpoint-sass/stylesheets'
],
outputStyle: 'nested',
sourceMap: true
},
files: {
'<%= global_vars.theme_dist_css %>/style.css': '<%= global_vars.theme_src_scss %>/style.scss'
}
}
},
autoprefixer: {
dist: {
options: {
map: true
},
expand: true,
flatten: true,
src: [
'<%= global_vars.theme_src_scss %>/*.css'
],
dest: ['<%= global_vars.theme_dist_css %>/']
}
},
// copy bootstrap asset
copy: {
main: {
files: [{
expand: true,
src: [
'node_modules/bootstrap/dist/js/bootstrap.js',
'node_modules/jquery-match-height/dist/jquery.matchHeight.js'
],
dest: '<%= global_vars.theme_src_js %>',
flatten: true
}]
}
},
// compress js
uglify: {
dist: {
options: {
sourceMap: true,
includeSources: true
},
files: [{
expand: true,
cwd: '<%= global_vars.theme_src_js %>',
src: ['*.js', '*.min.js'],
dest: '<%= global_vars.theme_dist_js %>',
rename: function (dst, src) {
return dst + '/' + src.replace('.js', '.min.js');
}
}]
}
},
// linting
sasslint: {
options: {
configFile: '.sass-lint.yml'
},
files: ['<%= global_vars.theme_src_scss %>/**/*.scss']
},
jshint: {
options: {
curly: true,
eqeqeq: true,
eqnull: true,
browser: true,
globals: {
jQuery: true
},
ignores: [
'<%= global_vars.theme_src_js %>/bootstrap.js',
'<%= global_vars.theme_src_js %>/popper.js',
]
},
files: ['<%= global_vars.theme_src_js %>/*.js']
},
// watch
watch: {
grunt: { files: ['Gruntfile.js'] },
sass: {
files: ['<%= sasslint.files %>'],
tasks: ['sass', 'autoprefixer', 'sasslint'],
options: {
livereload: true
}
},
js: {
files: ['<%= jshint.files %>'],
tasks: ['jshint']
}
},
});
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-sass-globbing');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-sass-lint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('build', ['sasslint', 'sass_globbing', 'sass', 'autoprefixer', 'copy', 'uglify']);
grunt.registerTask('default', ['build', 'watch']);
};