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

Make sass errors clearer to the user #990

Merged
merged 2 commits into from
Mar 19, 2021
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Fixes

- [Pull request #995: Allow Node 15 to be used](https://github.com/alphagov/govuk-prototype-kit/pull/995)
- [Pull request #990: Make sass errors clearer to the user](https://github.com/alphagov/govuk-prototype-kit/pull/990)

# 9.12.1 (Patch release)

Expand Down
13 changes: 11 additions & 2 deletions gulp/sass.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const fs = require('fs')

const extensions = require('../lib/extensions/extensions')
const config = require('./config.json')
const stylesheetDirectory = config.paths.public + 'stylesheets'

gulp.task('sass-extensions', function (done) {
const fileContents = '$govuk-extensions-url-context: "/extension-assets"; ' + extensions.getFileSystemPaths('sass')
Expand All @@ -24,9 +25,17 @@ gulp.task('sass-extensions', function (done) {
gulp.task('sass', function () {
return gulp.src(config.paths.assets + '/sass/*.scss')
.pipe(sourcemaps.init())
.pipe(sass({ outputStyle: 'expanded' }).on('error', sass.logError))
.pipe(sass({ outputStyle: 'expanded' }).on('error', function (error) {
// write a blank application.css to force browser refresh on error
if (!fs.existsSync(stylesheetDirectory)) {
fs.mkdirSync(stylesheetDirectory)
}
fs.writeFileSync(path.join(stylesheetDirectory, 'application.css'), '')
console.error('\n', error.messageFormatted, '\n')
this.emit('end')
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.paths.public + '/stylesheets/'))
.pipe(gulp.dest(stylesheetDirectory))
})

gulp.task('sass-documentation', function () {
Expand Down
2 changes: 1 addition & 1 deletion start.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function runGulp () {
const spawn = require('cross-spawn')

process.env.FORCE_COLOR = 1
var gulp = spawn('./node_modules/.bin/gulp')
var gulp = spawn('./node_modules/.bin/gulp', ['--log-level', '-L'])
gulp.stdout.pipe(process.stdout)
gulp.stderr.pipe(process.stderr)
process.stdin.pipe(gulp.stdin)
Expand Down