Skip to content

Commit

Permalink
make sass errors clearer to the user
Browse files Browse the repository at this point in the history
  • Loading branch information
joelanman committed Feb 22, 2021
1 parent be60d39 commit 04f520b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 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 @@ -21,12 +22,20 @@ gulp.task('sass-extensions', function (done) {
fs.writeFile(path.join(config.paths.lib + 'extensions', '_extensions.scss'), fileContents, done)
})

gulp.task('sass', function () {
gulp.task('sass', function (done) {
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 04f520b

Please sign in to comment.