mirror of
https://github.com/cockpit-project/cockpit.git
synced 2026-11-03 21:49:50 -09:00
Stop hardcoding 'dist/' all over the place. We already do it once in the esbuild configuration blob, and that's enough. The other places (and particularly the plugins) should be reading it from there. For the qunit plugin, remove a hardcoded instance of 'qunit/'.
18 lines
599 B
JavaScript
18 lines
599 B
JavaScript
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
// always start with a fresh dist/ directory, to change between development and production, or clean up gzipped files
|
|
export const cleanPlugin = ({ subdir = '' } = {}) => ({
|
|
name: 'clean-dist',
|
|
setup(build) {
|
|
build.onStart(() => {
|
|
try {
|
|
fs.rmSync(path.resolve(build.initialOptions.outdir, subdir), { recursive: true });
|
|
} catch (e) {
|
|
if (e.code !== 'ENOENT')
|
|
throw e;
|
|
}
|
|
});
|
|
}
|
|
});
|