Skip to content

Commit

Permalink
Centralise configuration for handling Sass deprecations
Browse files Browse the repository at this point in the history
This will reduce the risk that part of the build still show deprecations when others don't.
  • Loading branch information
romaricpascal committed Nov 11, 2024
1 parent 409527b commit ca9734e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 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}

Check failure on line 2 in shared/config/sass.js

View workflow job for this annotation

GitHub Actions / TypeScript compiler (windows-latest)

Generic type 'Options<sync>' requires 1 type argument(s).
*/
const deprecationOptions = {
silenceDeprecations: ['slash-div', 'mixed-decls', 'import', 'global-builtin'],
quietDeps: true
}

module.exports = {
deprecationOptions
}
18 changes: 3 additions & 15 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,13 +18,7 @@ const sassPaths = [
async function compileSassFile(path, options = {}) {
return compileAsync(path, {
loadPaths: sassPaths,
silenceDeprecations: [
'slash-div',
'mixed-decls',
'import',
'global-builtin'
],
quietDeps: true,
...sassConfig.deprecationOptions,
...options
})
}
Expand All @@ -39,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
10 changes: 2 additions & 8 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,13 +80,7 @@ export async function compileStylesheet([
alertColor: true,

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

// Enable source maps
sourceMap: true,
Expand Down

0 comments on commit ca9734e

Please sign in to comment.