feat: addCopyRule removeCopyRule helpers

This commit is contained in:
Igor Randjelovic
2020-12-01 20:23:56 +01:00
committed by Nathan Walker
parent a014bbffb8
commit 1086c6f9b3
5 changed files with 60 additions and 24 deletions

View File

@ -0,0 +1,36 @@
import CopyWebpackPlugin from 'copy-webpack-plugin';
import { getEntryDirPath } from './project';
/**
* @internal
*/
export let copyRules = new Set([]);
export function addCopyRule(glob: string) {
copyRules.add(glob);
}
export function removeCopyRule(glob: string) {
copyRules.delete(glob);
}
/**
* @internal
*/
export function applyCopyRules(config) {
config.plugin('CopyWebpackPlugin').use(CopyWebpackPlugin, [
{
patterns: Array.from(copyRules).map((glob) => ({
from: glob,
context: getEntryDirPath(),
noErrorOnMissing: true,
globOptions: {
dot: false,
// todo: ignore AppResources if inside app folder!
// ignore: [``]
},
})),
},
]);
}