Files
vscode-codeql/extensions/ql-vscode/gulpfile.ts/webpack.ts
Koen Vlaswinkel 7a7092de0d Add eslint-plugin-import
It seems like we had some rules that disabled rules of this plugin, but
we didn't actually have it installed. I've now installed it, used the
recommended configuration, and removed our own disable rules. I've fixed
any errors that this introduced.
2023-12-21 17:02:37 +01:00

58 lines
1.2 KiB
TypeScript

import { Configuration, Stats, webpack } from "webpack";
import { config } from "./webpack.config";
export function compileView(cb: (err?: Error) => void) {
doWebpack(config, true, cb);
}
export function watchView(cb: (err?: Error) => void) {
const watchConfig = {
...config,
watch: true,
watchOptions: {
aggregateTimeout: 200,
poll: 1000,
},
};
doWebpack(watchConfig, false, cb);
}
function doWebpack(
internalConfig: Configuration,
failOnError: boolean,
cb: (err?: Error) => void,
) {
const resultCb = (error: Error | undefined, stats?: Stats) => {
if (error) {
cb(error);
}
if (stats) {
console.log(
stats.toString({
errorDetails: true,
colors: true,
assets: false,
builtAt: false,
version: false,
hash: false,
entrypoints: false,
timings: false,
modules: false,
errors: true,
}),
);
if (stats.hasErrors()) {
if (failOnError) {
cb(new Error("Compilation errors detected."));
return;
} else {
console.error("Compilation errors detected.");
}
}
cb();
}
};
webpack(internalConfig, resultCb);
}