mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: addCopyRule removeCopyRule helpers
This commit is contained in:
36
packages/webpack5/src/helpers/copyRules.ts
Normal file
36
packages/webpack5/src/helpers/copyRules.ts
Normal 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: [``]
|
||||
},
|
||||
})),
|
||||
},
|
||||
]);
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
import { merge } from 'webpack-merge';
|
||||
|
||||
import { addCopyRule, removeCopyRule } from './copyRules';
|
||||
import { determineProjectFlavor } from './flavor';
|
||||
import { error, info, warn } from './log';
|
||||
import { getValue } from './config';
|
||||
import {
|
||||
getAllDependencies,
|
||||
hasDependency,
|
||||
getDependencyPath,
|
||||
} from './dependencies';
|
||||
import { determineProjectFlavor } from './flavor';
|
||||
import { error, info, warn } from './log';
|
||||
import { getValue } from './config';
|
||||
import {
|
||||
getAbsoluteDistPath,
|
||||
getDistPath,
|
||||
@@ -22,8 +23,11 @@ import {
|
||||
// as this generates nicer typings
|
||||
// that show all the utils inline
|
||||
// rather than imports to types
|
||||
// todo: maybe use api-extractor instead
|
||||
export default {
|
||||
merge,
|
||||
addCopyRule,
|
||||
removeCopyRule,
|
||||
config: {
|
||||
getValue,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user