-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
177 lines (158 loc) · 5.48 KB
/
gulpfile.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
// -------------------------------------
//
// Gulpfile
//
// -------------------------------------
//
// Available tasks:
// `gulp`
// `gulp build`
// `gulp build:dev`
// `gulp clean`
// `gulp clean:css`
// `gulp clean:styleguide`
// `gulp compile:sass`
// `gulp compile:styleguide`
// `gulp lint:js`
// `gulp lint:css`
// `gulp minify:css`
// `gulp serve`
// `gulp test:css`
// `gulp watch`
// `gulp watch:js`
// `gulp watch:sass`
// `gulp watch:styleguide`
//
// -------------------------------------
// -------------------------------------
// Modules
// -------------------------------------
//
// gulp : The streaming build system
// gulp-autoprefixer : Prefix CSS
// gulp-concat : Concatenate files
// gulp-clean-css : Minify CSS
// gulp-load-plugins : Automatically load Gulp plugins
// gulp-parker : Stylesheet analysis tool
// gulp-plumber : Prevent pipe breaking from errors
// gulp-rename : Rename files
// gulp-sass : Compile Sass
// gulp-sass-glob : Provide Sass Globbing
// gulp-sass-lint : Lint Sass
// gulp-size : Print file sizes
// gulp-sourcemaps : Generate sourcemaps
// gulp-uglify : Minify JavaScript with UglifyJS
// gulp-util : Utility functions
// gulp-watch : Watch stream
// browser-sync : Device and browser testing tool
// del : delete
// eslint : JavaScript code quality tool
// kss : Living Style Guide Generator
// run-sequence : Run a series of dependent Gulp tasks in order
// -------------------------------------
// -------------------------------------
// Front-End Dependencies
// -------------------------------------
// breakpoint-sass : Really Simple Media Queries with Sass
// kss : A methodology for documenting CSS and building style guides
// node-sass : Wrapper around libsass
// node-sass-import-once : Custom importer for node-sass that only allows a file to be imported once
// susy : Sass power-tools for web layout
// typey : A complete framework for working with typography in sass
// -------------------------------------
var gulp = require('gulp');
// Setting pattern this way allows non gulp- plugins to be loaded as well.
var plugins = require('gulp-load-plugins')({
pattern: '*',
rename: {
'node-sass-import-once': 'importOnce',
'gulp-sass-glob': 'sassGlob',
'run-sequence': 'runSequence',
'gulp-clean-css': 'cleanCSS',
'gulp-stylelint': 'gulpStylelint'
}
});
// Used to generate relative paths for style guide output.
var path = require('path');
// These are used in the options below.
var paths = {
styles: {
source: 'themes/custom/lightup/sass/',
destination: 'themes/custom/lightup/css/'
},
scripts: 'themes/custom/lightup/js/',
images: 'themes/custom/lightup/img/',
styleGuide: 'themes/custom/lightup/styleguide'
};
// These are passed to each task.
var options = {
// ----- CSS ----- //
css: {
files: paths.styles.destination + '**/*.css',
file: paths.styles.destination + '/styles.css',
destination: paths.styles.destination
},
// ----- Sass ----- //
sass: {
files: paths.styles.source + '**/*.scss',
file: paths.styles.source + 'styles.scss',
destination: paths.styles.destination
},
// ----- JS ----- //
js: {
files: paths.scripts + '**/*.js',
destination: paths.scripts
},
// ----- Images ----- //
images: {
files: paths.images + '**/*.{png,gif,jpg,svg}',
destination: paths.images
},
// ----- eslint ----- //
jsLinting: {
files: {
theme: [
paths.scripts + '**/*.js',
'!' + paths.scripts + '**/*.min.js'
],
gulp: [
'gulpfile.js',
'gulp-tasks/**/*'
]
}
},
// ----- KSS Node ----- //
styleGuide: {
source: [
paths.styles.source
],
builder: 'builder/twig',
destination: 'styleguide/',
css: [
path.relative(paths.styleGuide, paths.styles.destination + 'styles.css'),
path.relative(paths.styleGuide, paths.styles.destination + 'style-guide-only/kss-only.css')
],
js: [],
homepage: 'style-guide-only/homepage.md',
title: 'Living Style Guide'
}
};
// Tasks
require('./themes/custom/lightup/gulp-tasks/build')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/clean')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/clean-css')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/clean-styleguide')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/compile-sass')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/compile-styleguide')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/default')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/lint-js')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/lint-css')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/minify-css')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/test-css')(gulp, plugins, options);
require('./themes/custom/lightup/gulp-tasks/watch')(gulp, plugins, options);
// Credits:
//
// - http://drewbarontini.com/articles/building-a-better-gulpfile/
// - https://teamgaslight.com/blog/small-sips-of-gulp-dot-js-4-steps-to-reduce-complexity
// - http://cgit.drupalcode.org/zen/tree/STARTERKIT/gulpfile.js?h=7.x-6.x
// - https://github.com/google/web-starter-kit/blob/master/gulpfile.js