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
This commit is contained in:
Martin Pitt 2020-12-16 17:47:20 +01:00 committed by GitHub
parent 18354174de
commit 8821db1daf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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: {