From 8821db1daf14eb08bcec8892f3a4c3917cb968b7 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 16 Dec 2020 17:47:20 +0100 Subject: [PATCH] webpack: Check if sassc is installed If so, show the versions, which may be useful for comparing builds. If not, show an useful error message. Previously, you were left with ~ 80 identical unintelligible error messages and leftover temporary directories. Closes #404 Fixes #391 --- webpack.config.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/webpack.config.js b/webpack.config.js index e524c9a..cb58674 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,5 @@ const path = require("path"); +const childProcess = require('child_process'); const copy = require("copy-webpack-plugin"); const extract = require("mini-css-extract-plugin"); const webpack = require("webpack"); @@ -47,6 +48,18 @@ const babel_loader = { } } +/* check if sassc is available, to avoid unintelligible error messages */ +try { + childProcess.execFileSync('sassc', ['--version'], { stdio: ['pipe', 'inherit', 'inherit'] }); +} catch (e) { + if (e.code === 'ENOENT') { + console.error("ERROR: You need to install the 'sassc' package to build this project."); + process.exit(1); + } else { + throw e; + } +} + module.exports = { mode: production ? 'production' : 'development', resolve: {