diff options
author | 2021-08-15 22:51:01 +0530 | |
---|---|---|
committer | 2021-08-15 22:51:01 +0530 | |
commit | 889d3802548b2f591312eaf3ced22700e8524160 (patch) | |
tree | 770920454b6f10bc026477b456907e44cc5642c9 | |
parent | docs: updated CHANGELOG.md [skip ci] (diff) | |
download | ferdium-app-889d3802548b2f591312eaf3ced22700e8524160.tar.gz ferdium-app-889d3802548b2f591312eaf3ced22700e8524160.tar.zst ferdium-app-889d3802548b2f591312eaf3ced22700e8524160.zip |
refactor: remove duplication of code blocks handling stylesheets in gulp
-rw-r--r-- | gulpfile.babel.js | 91 |
1 files changed, 11 insertions, 80 deletions
diff --git a/gulpfile.babel.js b/gulpfile.babel.js index 02e42e788..7311fc633 100644 --- a/gulpfile.babel.js +++ b/gulpfile.babel.js | |||
@@ -62,40 +62,36 @@ const paths = { | |||
62 | watch: 'src/**/*.html', | 62 | watch: 'src/**/*.html', |
63 | }, | 63 | }, |
64 | styles: { | 64 | styles: { |
65 | src: 'src/styles/main.scss', | 65 | src: [ |
66 | 'src/styles/main.scss', | ||
67 | 'src/styles/vertical.scss', | ||
68 | 'src/styles/animations.scss', | ||
69 | ], | ||
66 | dest: 'build/styles', | 70 | dest: 'build/styles', |
67 | watch: 'src/styles/**/*.scss', | 71 | watch: 'src/styles/**/*.scss', |
68 | }, | 72 | }, |
69 | verticalStyle: { | ||
70 | src: 'src/styles/vertical.scss', | ||
71 | dest: 'build/styles', | ||
72 | }, | ||
73 | animations: { | ||
74 | src: 'src/styles/animations.scss', | ||
75 | dest: 'build/styles', | ||
76 | }, | ||
77 | javascripts: { | 73 | javascripts: { |
78 | src: 'src/**/*.js', | 74 | src: 'src/**/*.js', |
79 | dest: 'build/', | 75 | dest: 'build/', |
80 | watch: [ | 76 | watch: [ |
81 | // 'packages/**/*.js', | ||
82 | 'src/**/*.js', | 77 | 'src/**/*.js', |
78 | // 'packages/**/*.js', | ||
83 | ], | 79 | ], |
84 | }, | 80 | }, |
85 | typescripts: { | 81 | typescripts: { |
86 | src: 'src/**/*.ts', | 82 | src: 'src/**/*.ts', |
87 | dest: 'build/', | 83 | dest: 'build/', |
88 | watch: [ | 84 | watch: [ |
89 | // 'packages/**/*.ts', | ||
90 | 'src/**/*.ts', | 85 | 'src/**/*.ts', |
86 | // 'packages/**/*.ts', | ||
91 | ], | 87 | ], |
92 | }, | 88 | }, |
93 | packages: { | 89 | packages: { |
94 | watch: 'packages/**/*', | 90 | watch: 'packages/**/*', |
95 | // dest: 'build/', | 91 | // dest: 'build/', |
96 | // watch: [ | 92 | // watch: [ |
97 | // // 'packages/**/*.js', | ||
98 | // 'src/**/*.js', | 93 | // 'src/**/*.js', |
94 | // // 'packages/**/*.js', | ||
99 | // ], | 95 | // ], |
100 | }, | 96 | }, |
101 | }; | 97 | }; |
@@ -136,11 +132,9 @@ export function mvSrc() { | |||
136 | [ | 132 | [ |
137 | `${paths.src}/*`, | 133 | `${paths.src}/*`, |
138 | `${paths.src}/*/**`, | 134 | `${paths.src}/*/**`, |
139 | `!${paths.javascripts.watch[1]}`, | 135 | `!${paths.javascripts.watch[0]}`, |
140 | `!${paths.typescripts.watch[1]}`, | 136 | `!${paths.typescripts.watch[0]}`, |
141 | `!${paths.src}/styles/**`, | 137 | `!${paths.src}/styles/**`, |
142 | `!${paths.src}/**/*.js`, | ||
143 | `!${paths.src}/**/*.ts`, | ||
144 | ], | 138 | ], |
145 | { since: gulp.lastRun(mvSrc) }, | 139 | { since: gulp.lastRun(mvSrc) }, |
146 | ) | 140 | ) |
@@ -212,68 +206,6 @@ export function styles() { | |||
212 | .pipe(connect.reload()); | 206 | .pipe(connect.reload()); |
213 | } | 207 | } |
214 | 208 | ||
215 | export function verticalStyle() { | ||
216 | return gulp | ||
217 | .src(paths.verticalStyle.src) | ||
218 | .pipe( | ||
219 | sassVariables( | ||
220 | Object.assign( | ||
221 | { | ||
222 | $env: getTargetEnv, | ||
223 | }, | ||
224 | ...styleConfig, | ||
225 | ), | ||
226 | ), | ||
227 | ) | ||
228 | .pipe( | ||
229 | sass({ | ||
230 | includePaths: ['./node_modules', '../node_modules'], | ||
231 | }).on('error', sass.logError), | ||
232 | ) | ||
233 | .pipe( | ||
234 | gulpIf( | ||
235 | !isDevBuild, | ||
236 | csso({ | ||
237 | // Only minify in production to speed up dev builds | ||
238 | restructure: false, // Don't restructure CSS, otherwise it will break the styles | ||
239 | }), | ||
240 | ), | ||
241 | ) | ||
242 | .pipe(gulp.dest(paths.verticalStyle.dest)) | ||
243 | .pipe(connect.reload()); | ||
244 | } | ||
245 | |||
246 | export function animations() { | ||
247 | return gulp | ||
248 | .src(paths.animations.src) | ||
249 | .pipe( | ||
250 | sassVariables( | ||
251 | Object.assign( | ||
252 | { | ||
253 | $env: getTargetEnv, | ||
254 | }, | ||
255 | ...styleConfig, | ||
256 | ), | ||
257 | ), | ||
258 | ) | ||
259 | .pipe( | ||
260 | sass({ | ||
261 | includePaths: ['./node_modules', '../node_modules'], | ||
262 | }).on('error', sass.logError), | ||
263 | ) | ||
264 | .pipe( | ||
265 | gulpIf( | ||
266 | !isDevBuild, | ||
267 | csso({ | ||
268 | // Only minify in production to speed up dev builds | ||
269 | restructure: false, // Don't restructure CSS, otherwise it will break the styles | ||
270 | }), | ||
271 | ), | ||
272 | ) | ||
273 | .pipe(gulp.dest(paths.animations.dest)) | ||
274 | .pipe(connect.reload()); | ||
275 | } | ||
276 | |||
277 | export function processJavascripts() { | 209 | export function processJavascripts() { |
278 | return gulp | 210 | return gulp |
279 | .src( | 211 | .src( |
@@ -315,7 +247,6 @@ export function processTypescripts() { | |||
315 | export function watch() { | 247 | export function watch() { |
316 | gulp.watch(paths.packages.watch, mvLernaPackages); | 248 | gulp.watch(paths.packages.watch, mvLernaPackages); |
317 | gulp.watch(paths.styles.watch, styles); | 249 | gulp.watch(paths.styles.watch, styles); |
318 | gulp.watch(paths.verticalStyle.src, verticalStyle); | ||
319 | 250 | ||
320 | gulp.watch([paths.src, `${paths.javascripts.src}`, `${paths.styles.src}`], mvSrc); | 251 | gulp.watch([paths.src, `${paths.javascripts.src}`, `${paths.styles.src}`], mvSrc); |
321 | 252 | ||
@@ -344,7 +275,7 @@ export function recipeInfo() { | |||
344 | const build = gulp.series( | 275 | const build = gulp.series( |
345 | clean, | 276 | clean, |
346 | gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages, exportBuildInfo), | 277 | gulp.parallel(mvSrc, mvPackageJson, mvLernaPackages, exportBuildInfo), |
347 | gulp.parallel(html, processJavascripts, processTypescripts, styles, verticalStyle, animations, recipes, recipeInfo), | 278 | gulp.parallel(html, processJavascripts, processTypescripts, styles, recipes, recipeInfo), |
348 | ); | 279 | ); |
349 | export { build }; | 280 | export { build }; |
350 | 281 | ||