// SPDX-License-Identifier: LGPL-2.1-or-laterimport 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 filesexport 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;}});}});