Skip to content

Commit 8235e62

Browse files
committed
Add ddd-styles-partial-sort sync hook to gulp build to allow _reactium-style.scss partials to be sorted.
1 parent 7ee749d commit 8235e62

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

.core/gulp.tasks.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,14 @@ $assets: (
540540
};
541541

542542
const dddStylesPartial = done => {
543+
const SassPartialSort = ReactiumGulp.Utils.registryFactory(
544+
'SassPartialSort',
545+
'id',
546+
ReactiumGulp.Utils.Registry.MODES.CLEAN,
547+
);
548+
549+
ReactiumGulp.Hook.runSync('ddd-styles-partial-sort', SassPartialSort);
550+
543551
const stylePartials = globby
544552
.sync(config.src.styleDDD)
545553
.map(partial => {
@@ -552,7 +560,23 @@ $assets: (
552560
path.resolve(rootPath, partial),
553561
);
554562
})
555-
.map(partial => partial.replace(/\.scss$/, ''));
563+
.map(partial => partial.replace(/\.scss$/, ''))
564+
.sort((a, b) => {
565+
const aMatch =
566+
SassPartialSort.list.find(({ pattern }) =>
567+
pattern.test(a),
568+
) || {};
569+
const bMatch =
570+
SassPartialSort.list.find(({ pattern }) =>
571+
pattern.test(b),
572+
) || {};
573+
const aOrder = op.get(aMatch, 'order', 0);
574+
const bOrder = op.get(bMatch, 'order', 0);
575+
576+
if (aOrder > bOrder) return 1;
577+
else if (bOrder > aOrder) return -1;
578+
return 0;
579+
});
556580

557581
const template = handlebars.compile(`
558582
// WARNING: Do not directly edit this file !!!!
@@ -649,6 +673,7 @@ $assets: (
649673
gulp.watch(config.watch.colors, gulp.task('styles:colors'));
650674
gulp.watch(config.watch.pluginAssets, gulp.task('styles:pluginAssets'));
651675
gulp.watch(config.watch.style, gulp.task('styles:compile'));
676+
gulp.watch(config.src.styleDDD, gulp.task('styles:partials'));
652677
gulpwatch(config.watch.markup, watcher);
653678
gulpwatch(config.watch.assets, watcher);
654679
const scriptWatcher = gulp.watch(

0 commit comments

Comments
 (0)