Skip to content

Commit

Permalink
use own clean plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx committed Mar 26, 2024
1 parent c60f8af commit aa83374
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
20 changes: 11 additions & 9 deletions packages/addon-dev/src/rollup-clean-plugin.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import globSync from 'fast-glob';
import { rmSync } from 'node:fs';
import { join } from 'node:path';
import walkSync from 'walk-sync';
import { rmSync } from 'fs';
import { join } from 'path';
import type { Plugin } from 'rollup';

export default function clean() {
export default function clean(): Plugin {
return {
name: 'clean',
writeBundle(options, bundle) {
const files = globSync.sync('*/**', {
cwd: options.dir,
const files = walkSync(options.dir!, {
globs: ['*/**'],
directories: false,
});
for (const file of files) {
if (!bundle[file]) {
rmSync(join(options.dir, file));
rmSync(join(options.dir!, file));
}
}
}
}
},
};
}
9 changes: 4 additions & 5 deletions packages/addon-dev/src/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { default as hbs } from './rollup-hbs-plugin';
import { default as gjs } from './rollup-gjs-plugin';
import { default as publicEntrypoints } from './rollup-public-entrypoints';
import { default as appReexports } from './rollup-app-reexports';
import type { Options as DelOptions } from 'rollup-plugin-delete';
import { default as clean } from 'rollup-plugin-delete';
import { default as keepAssets } from './rollup-keep-assets';
import { default as dependencies } from './rollup-addon-dependencies';
import { default as publicAssets } from './rollup-public-assets';
import { default as clean } from './rollup-clean-plugin';
import type { Plugin } from 'rollup';

export class Addon {
Expand Down Expand Up @@ -62,9 +61,9 @@ export class Addon {
}

// By default rollup does not clear the output directory between builds. This
// does that.
clean(options: DelOptions) {
return clean({ targets: `${this.#destDir}/*`, ...options });
// does that. It only deletes files that are not part of the generated bundle
clean() {
return clean();
}

// V2 Addons are allowed to contain imports of .css files. This tells rollup
Expand Down

0 comments on commit aa83374

Please sign in to comment.