-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
233 lines (212 loc) · 6.2 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
module.exports = function (grunt) {
'use strict';
var gulp = require('gulp'),
styleguide = require('sc5-styleguide');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jekyll: { // Task
options: { // Universal options
bundleExec: true,
src: '<%= app %>'
},
dist: { // Target
options: { // Target options
dest: '<%= dist %>',
config: '_config.yml'
}
},
serve: { // Another target
options: {
serve: true,
dest: '_site',
drafts: true,
future: true
}
}
},
// Grunt-sass
sass: {
dev: {
// Takes every file that ends with .scss from the scss
// directory and compile them into the css directory.
// Also changes the extension from .scss into .css.
// Note: file name that begins with _ are ignored automatically
files: [{
expand: true,
cwd: 'scss',
src: ['*.scss'],
dest: 'css',
ext: '.css'
}],
options: {
sourceMap: true,
outputStyle: 'expanded',
imagePath: "../"
}
},
dist: {
// Takes every file that ends with .scss from the scss
// directory and compile them into the css directory.
// Also changes the extension from .scss into .css.
// Note: file name that begins with _ are ignored automatically
files: [{
expand: true,
cwd: 'scss',
src: ['*.scss'],
dest: 'css',
ext: '.css'
}],
options: {
sourceMap: false,
outputStyle: 'compressed',
imagePath: "../"
}
}
},
// Grunt-contrib-watch
watch: {
sass: {
// Watches all Sass or Scss files within the scss folder and one level down.
// If you want to watch all scss files instead, use the "**/*" globbing pattern
files: ['{,*/}**', '!node_modules/**', '!_site/**', '!css/**', '!styleguide/**'],
//files: ['gruntfile.js']
// runs the task `dev` whenever any watched file changes
tasks: ['dev'],
},
options: {
// livereload: true,
// spawn: false
}
},
// run tasks in parallel
concurrent: {
serve: [
'watch',
//'jekyll:serve'
'browserSync'
],
options: {
logConcurrentOutput: true
}
},
// lint the sass files
sasslint: {
options: {
configFile: '.sass-lint.yml',
},
target: ['scss/**/*.scss']
},
// Browsersync
browserSync: {
bsFiles: {
src : ['_site/css/*.css', '_site/styleguide/style.css']
},
options: {
server: {
baseDir: "./_site/"
},
open: false
}
},
// Style guide generation
gulp: {
'styleguide-generate': function() {
var outputPath = 'styleguide';
return gulp.src(['scss/**/*.scss'])
.pipe(styleguide.generate({
title: 'My Styleguide',
// If you want to have the styleguide available on http://localhost:2000 uncomment the next three lines
// and comment out the line "appRoot".
// You should then also ignore the styleguide folder in _config.yml then the styleguide would not be
// deployed with the live site.
// If you want to deploy with the live site and have it available under /styleguide leave like this.
//server: true,
//rootPath: outputPath,
//port: 2000,
appRoot: '/styleguide',
overviewPath: 'README.md'
}))
.pipe(gulp.dest(outputPath));
},
'styleguide-applystyles': function() {
gulp.src('css/style.css')
.pipe(styleguide.applyStyles())
.pipe(gulp.dest('styleguide'));
}
},
// Sass globbing (necessary for libSass)
sass_globbing: {
sass: {
files: {
'scss/_base.scss': 'scss/base/**/*.scss',
'scss/_includes.scss': 'scss/includes/**/*.scss',
'scss/_partials.scss': 'scss/partials/**/*.scss',
'scss/_variables.scss': 'scss/variables/**/*.scss',
},
options: {
useSingleQuotes: false,
signature: '// Hello, World!'
}
}
},
// Not needed for now as it seems uglify does a better job.
//concat: {
// options: {
// separator: ';'
// },
// js: {
// src: [
// 'js/src/script.js'
// ],
// dest: 'js/concat.js'
// }
//},
uglify: {
dev: {
options: {
sourceMap: true,
sourceMapName: 'js/sourcemap.map',
beautify: true
},
files: {
'js/script.js': ['js/src/script.js']
}
},
dist: {
options: {
sourceMap: false,
},
files: {
'js/script.js': ['js/src/script.js']
}
}
},
jshint: {
all: ['Gruntfile.js', 'js/src/*.js']
},
clean: {
js: ["js/*", "!js/src"],
css: ["css/*", "!css/bac"],
jekyll: ["_site/*"],
styleguide: ["styleguide/*"]
}
});
grunt.loadNpmTasks('grunt-jekyll');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-concurrent');
grunt.loadNpmTasks('grunt-sass-lint');
grunt.loadNpmTasks('grunt-browser-sync');
grunt.loadNpmTasks('grunt-gulp');
grunt.loadNpmTasks('grunt-sass-globbing');
//grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
// Default task(s).
grunt.registerTask('default', ['dev', 'concurrent']);
grunt.registerTask('dev', ['int', 'sass_globbing', 'sass:dev', 'uglify:dev', 'gulp:styleguide-generate', 'gulp:styleguide-applystyles', 'jekyll:dist']);
grunt.registerTask('dist', ['clean', 'sass_globbing', 'sass:dist', 'uglify:dist', 'gulp', 'jekyll:dist', 'int']);
grunt.registerTask('int', ['jshint', 'sasslint']);
};