Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update silenced warnings for Sass compiler #5494

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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