-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
253 lines (235 loc) · 8.27 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
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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
var path = require('path');
var gulp = require('gulp');
// Tasks
var fs = require('fs');
// 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',
'gulp-eslint': 'gulpEslint',
'gulp-babel': 'babel',
'gulp-util': 'gutil',
'gulp-notify': 'notify',
'gulp-concat': 'concat',
'gulp-uglify': 'uglify',
'gulp-imagemin': 'imagemin',
'gulp-twig' : 'twig',
'gulp-data' : 'data',
'glob': 'glob',
'flatten': 'gulp-flatten',
'gulp-svg-sprite': 'svgsprite',
'gulp-append-prepend': 'gap'
}
});
//Default paths.
var paths = {
styles: {
source: 'src/templates/',
destination: 'assets/css/'
},
scripts: {
source: 'src/templates/',
destination: 'assets/js',
},
scriptsVendorFiles: [
'node_modules/bootstrap/dist/js/bootstrap.js',
],
images: {
source: 'src/media/images/',
destination: 'assets/images/'
},
fonts: {
source: 'src/fonts/',
destination: 'assets/fonts/'
},
styleGuide: 'styleguide',
twigPages: {
src: 'src/templates/' ,
componentsSrc: 'src/templates/01-components/' ,
componentBlocksSrc: 'src/templates/02-component-blocks/' ,
pagesSrc: 'src/templates/03-pages/' ,
destination: 'assets/pages/',
componentsDestination:'assets/pages/01-components',
componentBlocksDestination:'assets/pages/02-component-blocks',
pagesDestination:'assets/pages/03-pages',
componentTemplateSrc: 'src/templates/component-template.twig',
componentBlockTemplateSrc: 'src/templates/component-block-template.twig'
},
svg : {
source: 'src/media/svgs',
destination: 'assets/svg',
prefix: {
dev: '',
pro: '/svg/sprite'
}
}
};
//Default options.
var options = {
drupalLibraries: {
destination:'./generated.libraries.yml'
},
// ----- Browsersync ----- //
browserSync: {
// Put your local site URL here to prevent Browsersync
// from prompting you to add additional scripts to your page.
// open: 'external',
//xip: true,
//logConnections: true
server: {baseDir: ['assets']},
startPath: "/pages",
port: 3005,
online: false,
open: true,
//ghostMode: false,
logConnections: true,
},
// ----- CSS ----- //
css: {
files: path.join(paths.styles.destination, '**/*.css'),
file: path.join(paths.styles.destination, '/styles.css'),
destination: path.join(paths.styles.destination)
},
// ----- Sass ----- //
sass: {
files: path.join(paths.styles.source, '/**/*.scss'),
file: path.join(paths.styles.source, 'styles.scss'),
destination: path.join(paths.styles.destination),
AUTOPREFIXER_BROWSERS: [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 9',
'opera >= 23',
'ios >= 8',
'android >= 4.4',
'bb >= 10'
]
},
// ----- JS ----- //
js: {
files: path.join(paths.scripts.source, '**/*.js'),
compiledFiles: path.join(paths.scripts.destination, '**/*.js'),
vendorFiles: paths.scriptsVendorFiles,
destination: path.join(paths.scripts.destination),
vendorDestination: path.join(paths.scripts.destination,'vendors')
},
// ----- eslint ----- //
jsLinting: {
files: {
theme: [
paths.scripts.source + '**/*.js',
'!' + paths.scripts.source + '**/*.min.js'
],
gulp: [
'gulpfile.js',
'gulp-tasks/**/*'
]
}
},
// ----- Fonts ----- //
fonts: {
files: paths.fonts.source + '**/*.{ttf,woff,otf,eot,svg,woff2}',
destination: paths.fonts.destination
},
// ----- Images ----- //
images: {
files: paths.images.source + '**/*.{png,gif,jpg,svg,xml,webmanifest}',
destination: paths.images.destination
},
// ----- TWIG pages ---- //
twigPages: {
baseSrc: path.join(paths.twigPages.src),
src: path.join(paths.twigPages.src, '/*.twig'),
componentsSrc: path.join(paths.twigPages.componentsSrc, '/**/*.twig'),
componentBlocksSrc: path.join(paths.twigPages.componentBlocksSrc, '/**/*.twig'),
pagesSrc: path.join(paths.twigPages.pagesSrc, '/**/*.twig'),
allSrc: path.join(paths.twigPages.src, '/**/*'), //Needed for watch task
destination: path.join(paths.twigPages.destination),
componentsDestination: path.join(paths.twigPages.componentsDestination),
componentBlocksDestination: path.join(paths.twigPages.componentBlocksDestination),
pagesDestination: path.join(paths.twigPages.pagesDestination),
componentTemplateSrc: path.join(paths.twigPages.componentTemplateSrc),
componentBlockTemplateSrc: path.join(paths.twigPages.componentBlockTemplateSrc)
},
// ------ pa11y ----- //
pa11y: {
urls: [ // An array of urls to test.
// For testing in a travis environment:
// 'http://127.0.0.1:8888',
// 'http://127.0.0.1:8888/themes/custom/yourtheme/styleguide'
'http://localhost:8000',
'http://localhost:8000/node/1'
],
failOnError: true, // fail the build on error
showFailedOnly: true, // show errors only and override reporter
reporter: 'console',
includeWarnings: true, // including warnings by default. - set it to false to disable
includeNotices: true, // including notices by default. - set it to false to disable
log: {
debug: console.log.bind(console),
error: console.error.bind(console),
info: console.info.bind(console)
},
standard: 'WCAG2AA', // choose from Section508, WCAG2A, WCAG2AA, and WCAG2AAA
page: {
settings: {
loadImages: false,
userName: '', // .htacess username
password: '' // .htaccess password
}
},
threshold: { // Set to -1 for no threshold.
errors: 1,
warnings: 10,
notices: -1
}
},
svg: {
files: path.join(paths.svg.source, '**/*.svg'),
destination: path.join(paths.svg.destination),
mode: {
symbol: { // symbol mode to build the SVG
render: {
css: true, // CSS output option for icon sizing
scss: true // SCSS output option for icon sizing
},
dest: 'sprite', // destination folder
prefix: '.svg--%s', // BEM-style prefix if styles rendered
sprite: 'sprite.svg', //generated sprite name
example: true // Build a sample page, please!
}
},
prefix: paths.svg.prefix
},
}
//Cargamos las task del gulp.
require('./gulp-tasks/svg')(gulp, plugins, options);
require('./gulp-tasks/twigpages')(gulp, plugins, options);
require('./gulp-tasks/browser-sync')(gulp, plugins, options);
require('./gulp-tasks/images')(gulp, plugins, options);
require('./gulp-tasks/clean-css')(gulp, plugins, options);
require('./gulp-tasks/clean-js')(gulp, plugins, options);
require('./gulp-tasks/clean-styleguide')(gulp, plugins, options);
require('./gulp-tasks/clean-twigpages')(gulp, plugins, options);
require('./gulp-tasks/clean')(gulp, plugins, options);
require('./gulp-tasks/compile-sass')(gulp, plugins, options);
require('./gulp-tasks/compile-js')(gulp, plugins, options);
require('./gulp-tasks/compile-styleguide')(gulp, plugins, options);
require('./gulp-tasks/lint-js')(gulp, plugins, options);
require('./gulp-tasks/lint-css')(gulp, plugins, options);
require('./gulp-tasks/minify-css')(gulp, plugins, options);
require('./gulp-tasks/minify-js')(gulp, plugins, options);
require('./gulp-tasks/fonts')(gulp, plugins, options);
require('./gulp-tasks/drupal-libraries')(gulp, plugins, options);
require('./gulp-tasks/build')(gulp, plugins, options);
require('./gulp-tasks/watch')(gulp, plugins, options);
require('./gulp-tasks/serve')(gulp, plugins, options);
require('./gulp-tasks/default')(gulp, plugins, options);
require('./gulp-tasks/drupal-dev')(gulp, plugins, options);