Skip to content

Commit

Permalink
Merge pull request #5494 from alphagov/silence-missed-sass-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
romaricpascal authored Nov 21, 2024
2 parents 3c8fec3 + eba858d commit 11f6e24
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
2 changes: 2 additions & 0 deletions shared/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const { NODE_ENV = 'development' } = process.env
*/
const paths = require('./paths')
const ports = require('./ports')
const sass = require('./sass')
const urls = require('./urls')

/**
Expand All @@ -25,6 +26,7 @@ module.exports = {
paths,
pkg,
ports,
sass,
urls,
version
}
11 changes: 11 additions & 0 deletions shared/config/sass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* @type {import('sass-embedded').Options<"async">}
*/
const deprecationOptions = {
silenceDeprecations: ['slash-div', 'mixed-decls', 'import', 'global-builtin'],
quietDeps: true
}

module.exports = {
deprecationOptions
}
13 changes: 3 additions & 10 deletions shared/helpers/tests.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { join } = require('path')

const { paths } = require('@govuk-frontend/config')
const { paths, sass: sassConfig } = require('@govuk-frontend/config')
const { compileAsync, compileStringAsync } = require('sass-embedded')

const sassPaths = [
Expand All @@ -18,8 +18,7 @@ const sassPaths = [
async function compileSassFile(path, options = {}) {
return compileAsync(path, {
loadPaths: sassPaths,
silenceDeprecations: ['slash-div', 'mixed-decls'],
quietDeps: true,
...sassConfig.deprecationOptions,
...options
})
}
Expand All @@ -34,13 +33,7 @@ async function compileSassFile(path, options = {}) {
async function compileSassString(source, options = {}) {
return compileStringAsync(source, {
loadPaths: sassPaths,
silenceDeprecations: [
'slash-div',
'mixed-decls',
'import',
'global-builtin'
],
quietDeps: true,
...sassConfig.deprecationOptions,
...options
})
}
Expand Down
5 changes: 2 additions & 3 deletions shared/tasks/styles.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFile } from 'fs/promises'
import { join, parse } from 'path'

import { paths } from '@govuk-frontend/config'
import { paths, sass as sassConfig } from '@govuk-frontend/config'
import { getListing } from '@govuk-frontend/lib/files'
import { packageTypeToPath } from '@govuk-frontend/lib/names'
import PluginError from 'plugin-error'
Expand Down Expand Up @@ -80,8 +80,7 @@ export async function compileStylesheet([
alertColor: true,

// Turn off dependency warnings
quietDeps: true,
silenceDeprecations: ['slash-div', 'mixed-decls'],
...sassConfig.deprecationOptions,

// Enable source maps
sourceMap: true,
Expand Down

0 comments on commit 11f6e24

Please sign in to comment.