@@ -5,13 +5,14 @@ import * as gulpLoadPlugins from 'gulp-load-plugins';
55import * as merge from 'merge-stream' ;
66import * as reporter from 'postcss-reporter' ;
77import * as stylelint from 'stylelint' ;
8- import { join } from 'path' ;
8+ import { join } from 'path' ;
99
10- import { APP_ASSETS , APP_SRC , BROWSER_LIST , CSS_SRC , ENV } from '../../config' ;
10+ import { APP_ASSETS , APP_SRC , BROWSER_LIST , CSS_SRC , ENV , DEPENDENCIES , ENABLE_SCSS } from '../../config' ;
1111
1212const plugins = < any > gulpLoadPlugins ( ) ;
1313
1414const isProd = ENV === 'prod' ;
15+ var stylesheetType = ENABLE_SCSS ? 'scss' : 'css' ;
1516
1617const processors = [
1718 doiuse ( {
@@ -22,35 +23,33 @@ const processors = [
2223 reporter ( { clearMessages : true } )
2324] ;
2425
25- /**
26- * Lints the component CSS files.
27- */
28- function lintComponentCss ( ) {
26+ function lintComponentStylesheets ( ) {
2927 return gulp . src ( [
30- join ( APP_SRC , '**' , '*.css' ) ,
31- '!' + join ( CSS_SRC , '**' , '*.css' )
32- ] )
33- . pipe ( isProd ? plugins . cached ( 'css-lint' ) : plugins . util . noop ( ) )
34- . pipe ( plugins . postcss ( processors ) ) ;
28+ join ( APP_SRC , '**' , `*.${ stylesheetType } ` ) ,
29+ `!${ join ( APP_SRC , 'assets' , '**' , '*.scss' ) } ` ,
30+ `!${ join ( CSS_SRC , '**' , '*.css' ) } `
31+ ] ) . pipe ( isProd ? plugins . cached ( 'css-lint' ) : plugins . util . noop ( ) )
32+ . pipe ( ENABLE_SCSS ? plugins . sassLint ( ) : plugins . postcss ( processors ) )
33+ . pipe ( ENABLE_SCSS ? plugins . sassLint . format ( ) : plugins . util . noop ( ) )
34+ . pipe ( ENABLE_SCSS ? plugins . sassLint . failOnError ( ) : plugins . util . noop ( ) ) ;
3535}
3636
37- /**
38- * Lints the external CSS files.
39- */
40- function lintExternalCss ( ) {
41- return gulp . src ( getExternalCss ( ) . map ( r => r . src ) )
37+ function lintExternalStylesheets ( ) {
38+ return gulp . src ( getExternalStylesheets ( ) . map ( r => r . src ) )
4239 . pipe ( isProd ? plugins . cached ( 'css-lint' ) : plugins . util . noop ( ) )
43- . pipe ( plugins . postcss ( processors ) ) ;
40+ . pipe ( ENABLE_SCSS ? plugins . sassLint ( ) : plugins . postcss ( processors ) )
41+ . pipe ( ENABLE_SCSS ? plugins . sassLint . format ( ) : plugins . util . noop ( ) )
42+ . pipe ( ENABLE_SCSS ? plugins . sassLint . failOnError ( ) : plugins . util . noop ( ) ) ;
4443}
4544
46- /**
47- * Returns the array of external CSS files.
48- */
49- function getExternalCss ( ) {
50- return APP_ASSETS . filter ( d => / \. c s s $ / . test ( d . src ) && ! d . vendor ) ;
45+ function getExternalStylesheets ( ) {
46+ let stylesheets = ENABLE_SCSS ? DEPENDENCIES : APP_ASSETS ;
47+ return stylesheets
48+ . filter ( d => new RegExp ( `\. ${ stylesheetType } $` )
49+ . test ( d . src ) && ! d . vendor ) ;
5150}
5251
5352/**
5453 * Executes the build process, linting the component and external CSS files using `stylelint`.
5554 */
56- export = ( ) => merge ( lintComponentCss ( ) , lintExternalCss ( ) ) ;
55+ export = ( ) => merge ( lintComponentStylesheets ( ) , lintExternalStylesheets ( ) ) ;
0 commit comments