Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 269d96f

Browse files
committed
feat(css): add CSScombx
1 parent 5b0a98f commit 269d96f

File tree

7 files changed

+39
-4
lines changed

7 files changed

+39
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ This stack core is to be included in your main project and sets up many Gulp tas
1414

1515
## Features
1616

17-
- SCSS => CSS compiling with LibSass, PostCSS, linting, and SourceMaps
17+
- SCSS => CSS compiling with LibSass, PostCSS, linting, CSScomb(x), and SourceMaps
1818
- JS compiling via Babel, linting and aggregation
1919
- WebPack module bundling
2020
- SVG => Font Icons compiling with support for adding mixins and classes to SCSS along with a demo page

docs/features/css.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@ You can create individual CSS files bundle, using the config:
1616
- `gulp css` - Compile SCSS to CSS
1717
- `gulp watch:css` - Watch and compile
1818
- `gulp validate:css` - Test SCSS with [gulp-sass-lint](https://github.com/sasstools/gulp-sass-lint), which uses [sass-lint](https://github.com/sasstools/sass-lint) (Pure node.js - no Ruby)
19+
- `gulp format:css` - Format SCSS with [gulp-csscombx](https://github.com/drugan/gulp-csscombx), which uses [csscombx](https://github.com/drugan/csscombx)
1920

2021
## Config
2122

2223
- `config.css.src` - Array of SCSS files
2324
- `config.css.dest` - String of Destination directory for CSS
24-
- `config.css.lint` - Boolean for if Linting should occur
25+
- `config.css.lint.enabled` - Boolean for if Linting should occur
26+
- `config.css.csscombx.enabled` - Boolean for if Formating should occur
2527
- `config.css.sourceComments` - Boolean - Enable comments written in CSS that shows SCSS source. **Don't turn on permanently**, it's useful if SourceMaps aren't working.
2628
- `config.css.autoPrefixerBrowsers` - Array of [Browsers to Support](https://github.com/ai/browserslist#queries) for Autoprefixer (used by PostCSS).
2729

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This stack core is to be included in your main project and sets up many Gulp tas
88

99
## Features
1010

11-
- SCSS => CSS compiling with LibSass, PostCSS, linting, and SourceMaps
11+
- SCSS => CSS compiling with LibSass, PostCSS, linting, CSScomb(x), and SourceMaps
1212
- JS compiling via Babel, linting and aggregation
1313
- WebPack module bundling
1414
- SVG => Font Icons compiling with support for adding mixins and classes to SCSS along with a demo page

docs/usage.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ $ npm install --save-dev eslint-config-drupal
6060
```
6161
And create a `.eslintrc.js` file:
6262
```javascript
63-
"use strict";
63+
'use strict';
6464
// rule reference: http://eslint.org/docs/rules
6565
// individual rule reference: http://eslint.org/docs/rules/NAME-OF-RULE
6666
@@ -89,4 +89,8 @@ module.exports = {
8989
};
9090
```
9191

92+
### CSScombx
93+
94+
The module follows the rules from [Drupal](https://www.drupal.org/docs/develop/standards/css/csscomb-settings-for-drupal-css-formatting-and-sort-tool).
95+
9296
---

gulpfile.default.yml

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ css:
1212
failOnError: true
1313
extraSrc:
1414
- scss/**/*.scss
15+
csscombx:
16+
enabled: false
17+
extraSrc:
18+
- scss/**/*.scss
1519
sourceComments: false
1620
sourceMap:
1721
enabled: false

lib/css.js

+24
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const plumber = require('gulp-plumber');
1111
const notify = require('gulp-notify');
1212
const flatten = require('gulp-flatten');
1313
const gulpif = require('gulp-if');
14+
const csscombx = require('gulp-csscombx');
1415
const sassdoc = require('sassdoc');
1516
const join = require('path').join;
1617
const del = require('del');
@@ -84,6 +85,21 @@ module.exports = (gulp, config, tasks) => {
8485

8586
gulp.task('validate:css', () => validateCss(true));
8687

88+
89+
function formatCss() {
90+
return gulp.src(config.css.csscombx.extraSrc
91+
? [].concat(config.css.src, config.css.csscombx.extraSrc)
92+
: config.css.src, { base: './' })
93+
.pipe(cached('format:css'))
94+
.pipe(csscombx())
95+
.pipe(gulp.dest('./'));
96+
}
97+
98+
formatCss.description = 'Format SCSS files';
99+
100+
gulp.task('format:css', () => formatCss());
101+
102+
87103
function docsCss() {
88104
return gulp.src(config.css.src)
89105
.pipe(sassdoc({
@@ -108,6 +124,9 @@ module.exports = (gulp, config, tasks) => {
108124

109125
function watchCss() {
110126
const watchTasks = [cssCompile];
127+
if (config.css.csscombx.enabled) {
128+
watchTasks.push('format:css');
129+
}
111130
if (config.css.lint.enabled) {
112131
watchTasks.push(validateCssWithNoExit);
113132
}
@@ -128,7 +147,12 @@ module.exports = (gulp, config, tasks) => {
128147

129148
tasks.compile.push('css');
130149

150+
if (config.css.csscombx.enabled) {
151+
tasks.validate.push('format:css');
152+
}
153+
131154
if (config.css.lint.enabled) {
155+
// must be after format:css
132156
tasks.validate.push('validate:css');
133157
}
134158

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"gulp-babel": "^7.0.0",
3535
"gulp-cached": "^1.1.1",
3636
"gulp-concat": "^2.6.1",
37+
"gulp-csscombx": "^4.2.1",
3738
"gulp-eslint": "^4.0.0",
3839
"gulp-flatten": "^0.3.1",
3940
"gulp-iconfont": "^9.0.2",

0 commit comments

Comments
 (0)