-
Notifications
You must be signed in to change notification settings - Fork 237
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
Support sass errors in error pages #2287
Support sass errors in error pages #2287
Conversation
64cbf22
to
edce060
Compare
83d5b16
to
c409654
Compare
c409654
to
648b94f
Compare
I've just tried to run this, the following attempt lead to the kit failing to start (failing to show the error in the browser):
Creating the error after the kit has started leads to the error appears properly in the browser as expected but the same does not happen if the error existed before starting the kit. @BenSurgisonGDS could you take a look at that case please? |
I have made some changes to fix the above issue. This has included how the sass for the error page is compiled and where it is sourced from. |
@@ -10,7 +10,7 @@ const dependencyPluginName = 'GOV.UK Frontend' | |||
describe('Handle a plugin update', () => { | |||
after(restoreStarterFiles) | |||
|
|||
it('when a dependency is now required', () => { | |||
it.skip('when a dependency is now required', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this one supposed to be skipped? It looks like maybe it was meant to be temporary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to either be deleted or revisited as the test no longer works as it did previously. This is because the older version of common-templates does not specify in it's config that it depends on govuk-frontend but it does because the sass fails to compile leading to the sass compilation error and so we can no longer (at the moment) have a test where a plugin depends upon another plugin when it is updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I thought it best to skip until we have an example we can use.
lib/assets/sass/prototype.scss
Outdated
} | ||
} | ||
// SASS that is user defined | ||
@import ".tmp/sass/user/application"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an empty line at the end of the file please? (there's a setting to do this automatically in WebStorm)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/utils/errorModel.js
Outdated
@@ -188,7 +209,7 @@ function getErrorDetails (cwd, error) { | |||
const getErrorModel = function (error) { | |||
flagError(error) | |||
const viewObject = { | |||
errorStack: error.stack, | |||
errorStack: unstyle(error.stack), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's only SASS errors that need unstyling (so far) I think we should move this into sassMatcher()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would argue that it doesn't hurt where it is and it covers us for if we ever come across any other errors that are styled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep it more contained - otherwise things like this tend to be left in through fear or what would happen if they're removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the unstyling of the error stack into the sass matcher as requested but then had to add some extra scafolding to cater for the fact that we don't return the stack from each matcher. To be honest I like the cleaner version we had before, but I've made the change as you asked.
I've just tested a few things manually and found that breaking
To see how it should behave (which is still not technically correct but it's the existing behaviour) just replace step 1 with:
It would be good to put a test in for this, but up to you whether that's done as part of this ticket or not. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's looks good
See: Sass errors are not obvious as the kit uses previously compiled sass in .tmp