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

PLATUI-3157 switch to dart-sass but add test to make sure we can still compile our sass with node-sass #395

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

oscarduignan
Copy link
Contributor

@oscarduignan oscarduignan commented Aug 19, 2024

migrated to dart-sass without having to change any of the import paths in the sass, so will still compile for people still using libsass (so hmrc teams using sbt-sassify) and also for people who move to dart-sass

@@ -10,19 +10,19 @@ const configPaths = require('../../config/paths.json');
const destinationPath = require('./destination-path');
const pkg = require('../../package.json');

const errorHandler = (error) => {
function errorHandler(error) {
Copy link
Contributor Author

@oscarduignan oscarduignan Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this because when it's an arrow function this.once/this.emit won't work (so we get an error in our error handler) const it's capturing the this to be this package I think - where as we want it to be kind of floating and refer to the context it's run in which will be some EventEmitter type thing that has a this.once https://nodejs.org/docs/latest/api/events.html

the iffy thing is that when using an arrow function the whole build blows up straight away when there is any error with css compiling - but without it, it continues on and only fails at the end - might be some tech debt here to generally tidy stuff up in case the first behaviour is what we want

console.error(e.messageFormatted || e);
throw e;
} finally {
await removeSymLinksIfPresent();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feels like we can probably tidy these tests up a bit t o make them clearer but for now I think it's ok to just duplicate stuff and have that come within some wider tech debt task to tidy up hmrc-frontend build & test config

@oscarduignan oscarduignan changed the title add test to make sure we can compile with node-sass PLATUI-3157 add test to make sure we can compile with node-sass Aug 19, 2024
@oscarduignan oscarduignan changed the title PLATUI-3157 add test to make sure we can compile with node-sass PLATUI-3157 switch to dart-sass and add test to make sure we can compile with node-sass Aug 19, 2024
@oscarduignan oscarduignan changed the title PLATUI-3157 switch to dart-sass and add test to make sure we can compile with node-sass PLATUI-3157 switch to dart-sass but add test to make sure we can still compile our sass with node-sass Aug 19, 2024
package.json Outdated
"govuk-frontend": "^5.4.1",
"accessible-autocomplete": "^2.0.4"
"accessible-autocomplete": "^2.0.4",
"govuk-frontend": "^5.4.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why npm always likes to swap these around in order when I install new stuff

@oscarduignan oscarduignan force-pushed the PLATUI-3157 branch 2 times, most recently from a3301f7 to e7ad10f Compare August 20, 2024 13:48

gulp.task('scss:compile-all-govuk-and-hmrc', () => gulp.src(`${configPaths.src}all-govuk-and-hmrc.scss`)
.pipe(plumber(errorHandler))
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: ['node_modules'],
includePaths: ['node_modules', 'node_modules/govuk-frontend/dist', 'node_modules/govuk-frontend/dist/govuk/components'],
Copy link
Contributor Author

@oscarduignan oscarduignan Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add a todo comment in the code explaining why we're adding these extra paths

still maintaining compat with node-sass (libsass)
@oscarduignan oscarduignan marked this pull request as ready for review October 22, 2024 14:51
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the difference is a slight 1px movement of the icon next to account menu - I couldn't recreate this difference in my browser - it is most likely due to gulp-sass rounding to 5 decimal places and dart-sass rounding to 10

@@ -40,7 +41,8 @@ gulp.task('scss:compile-accessible-autocomplete', () => gulp.src(`${configPaths.
.pipe(plumber(errorHandler))
.pipe(sourcemaps.init())
.pipe(sass({
includePaths: ['node_modules'],
includePaths: ['node_modules', 'node_modules/govuk-frontend/dist', 'node_modules/govuk-frontend/dist/govuk/components'],
quietDeps: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we don't have quietDeps then we get a load of deprecation warnings from stuff imported from govuk-frontend (I think) https://design-system.service.mod.gov.uk/get-started/silence-deprecation-warnings-in-dart-sass/ think with this we should still get warned about deprecations in our sass, just not in stuff imported from node_modules

@oscarduignan oscarduignan merged commit e2fc1f3 into main Oct 23, 2024
1 check passed
@oscarduignan oscarduignan deleted the PLATUI-3157 branch October 23, 2024 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants