diff --git a/shared/config/index.js b/shared/config/index.js index fc9ac1e021..b7610cdac5 100644 --- a/shared/config/index.js +++ b/shared/config/index.js @@ -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') /** @@ -25,6 +26,7 @@ module.exports = { paths, pkg, ports, + sass, urls, version } diff --git a/shared/config/sass.js b/shared/config/sass.js new file mode 100644 index 0000000000..97cbce151c --- /dev/null +++ b/shared/config/sass.js @@ -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 +} diff --git a/shared/helpers/tests.js b/shared/helpers/tests.js index 96acd9d5bf..35658b0f98 100644 --- a/shared/helpers/tests.js +++ b/shared/helpers/tests.js @@ -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 = [ @@ -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 }) } @@ -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 }) } diff --git a/shared/tasks/styles.mjs b/shared/tasks/styles.mjs index a9a3178481..aa980f916a 100644 --- a/shared/tasks/styles.mjs +++ b/shared/tasks/styles.mjs @@ -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' @@ -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,