Skip to content

Commit

Permalink
Merge pull request #990 from alphagov/sass-errors-2
Browse files Browse the repository at this point in the history
Make sass errors clearer to the user
  • Loading branch information
joelanman authored Mar 19, 2021
2 parents dd8a22f + f54027b commit 7e176ca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
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

0 comments on commit 7e176ca

Please sign in to comment.