<commit_before>/*********************************************************************************************************************
 *
 * SASS tasks.
 *
 *********************************************************************************************************************/

const { src, dest } = require( 'gulp' );
const sass          = require( 'gulp-dart-sass' );
const postcss       = require( 'gulp-postcss' );
const revUrl        = require( 'gulp-rev-urls' );
const linter        = require( 'gulp-sass-lint' );

// core stuff
const { sass: PATHS, build: OUTPUT } = require( '../paths' );
const { errorHandler } = require( '../utils/utils' );

/**
 * Compiles SASS to dev.
 *
 * @return {Stream} a gulp stream
 */
const sassDev = () =>
  src( PATHS.source )
    .pipe( errorHandler() )
    .pipe( require( 'gulp-sass-glob' )() )
    .pipe( sass({ outputStyle: 'expanded' }))
    .pipe( postcss([
      require( 'autoprefixer' ),
      require( 'postcss-short-border-radius' ),
      require( 'postcss-svg' )({ dirs: OUTPUT }),
      require( 'postcss-custom-properties' ),
      require( 'postcss-critical-css' )({
        outputPath: OUTPUT,
        minify:     false,
        preserve:   false
      }),
      require( '@lipemat/css-mqpacker' )({ sort: true })
    ]))
    .pipe( dest( OUTPUT ));

/**
 * Compiles SASS to build target.
 *
 * @return {Stream} a gulp stream
 */
const sassBuild = () =>
  src( `${OUTPUT}/*.css` )
    .pipe( errorHandler() )
    .pipe( postcss([
      require( 'cssnano' )({ autoprefixer: false }),
      require( 'postcss-sorting' ),
      require( '@lipemat/css-mqpacker' )({ sort: true })
    ]))
    .pipe( dest( OUTPUT ));

/**
 * Linting task.
 *
 * @return {Stream} a gulp stream
 */
const sassLint = () =>
  src( PATHS.source )
    .pipe( errorHandler() )
    .pipe( linter() )
    .pipe( linter.format() )
    .pipe( linter.failOnError() );

/**
 * Post-revision hook.
 *
 * @return {Stream} a gulp stream
 */
const sassPostRev = () =>
  src( `${OUTPUT}/*.css` )
    .pipe( revUrl({
      manifest:   `${OUTPUT}/assets.json`,
      transform:  ( obj, key, val ) => obj[`/${key}`] = val
    }));

/* Export things. */
module.exports = {
  init: [ sassDev ],
  watch: {
    files: PATHS.watch,
    tasks: [ sassDev, sassLint ]
  },
  build: [{ fn: sassDev, priority: 5 }, sassBuild ],
  noRev: [ 'critical*.css' ],
  afterRevision: [ sassPostRev ],
  lint: [ sassLint ]
};
<commit_msg>Fixing SASS build config<commit_after>/*********************************************************************************************************************
 *
 * SASS tasks.
 *
 *********************************************************************************************************************/

const { src, dest, series } = require( 'gulp' );
const sass          = require( 'gulp-dart-sass' );
const postcss       = require( 'gulp-postcss' );
const revUrl        = require( 'gulp-rev-urls' );
const linter        = require( 'gulp-sass-lint' );

// core stuff
const { sass: PATHS, build: OUTPUT } = require( '../paths' );
const { errorHandler } = require( '../utils/utils' );

/**
 * Compiles SASS to dev.
 *
 * @return {Stream} a gulp stream
 */
const sassDev = () =>
  src( PATHS.source )
    .pipe( errorHandler() )
    .pipe( require( 'gulp-sass-glob' )() )
    .pipe( sass({ outputStyle: 'expanded' }))
    .pipe( postcss([
      require( 'autoprefixer' ),
      require( 'postcss-short-border-radius' ),
      require( 'postcss-svg' )({ dirs: OUTPUT }),
      require( 'postcss-custom-properties' ),
      require( 'postcss-critical-css' )({
        outputPath: OUTPUT,
        minify:     false,
        preserve:   false
      }),
      require( '@lipemat/css-mqpacker' )({ sort: true })
    ]))
    .pipe( dest( OUTPUT ));

/**
 * Compiles SASS to build target.
 *
 * @return {Stream} a gulp stream
 */
const sassBuild = () =>
  src( `${OUTPUT}/*.css` )
    .pipe( errorHandler() )
    .pipe( postcss([
      require( 'cssnano' )({ autoprefixer: false }),
      require( 'postcss-sorting' ),
      require( '@lipemat/css-mqpacker' )({ sort: true })
    ]))
    .pipe( dest( OUTPUT ));

/**
 * Linting task.
 *
 * @return {Stream} a gulp stream
 */
const sassLint = () =>
  src( PATHS.source )
    .pipe( errorHandler() )
    .pipe( linter() )
    .pipe( linter.format() )
    .pipe( linter.failOnError() );

/**
 * Post-revision hook.
 *
 * @return {Stream} a gulp stream
 */
const sassPostRev = () =>
  src( `${OUTPUT}/*.css` )
    .pipe( revUrl({
      manifest:   `${OUTPUT}/assets.json`,
      transform:  ( obj, key, val ) => obj[`/${key}`] = val
    }));

/* Export things. */
module.exports = {
  init: [ sassDev ],
  watch: {
    files: PATHS.watch,
    tasks: [ sassDev, sassLint ]
  },
  build: series( sassDev, sassBuild ),
  noRev: [ 'critical*.css' ],
  afterRevision: [ sassPostRev ],
  lint: [ sassLint ]
};

{'fraction_non_alphanumeric': 0.2687487158413807, 'fraction_numerical': 0.0002054653790836244, 'mean_word_length': 2.891286970423661, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6470414', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1618, 'n_words': 362}