mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix(webpack): remove copy rules that don't match any files to avoid false watch triggers
This commit is contained in:

committed by
Nathan Walker

parent
fefac9f554
commit
eedc9c9eb1
@ -1,6 +1,7 @@
|
||||
import CopyWebpackPlugin from 'copy-webpack-plugin';
|
||||
import { basename, relative, resolve } from 'path';
|
||||
import Config from 'webpack-chain';
|
||||
import { sync as globbySync } from 'globby';
|
||||
|
||||
import { getProjectRootPath } from './project';
|
||||
import { getEntryDirPath } from './platform';
|
||||
@ -70,6 +71,15 @@ export function applyCopyRules(config: Config) {
|
||||
config.plugin('CopyWebpackPlugin').use(CopyWebpackPlugin, [
|
||||
{
|
||||
patterns: Array.from(copyRules)
|
||||
.filter((glob) => {
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
return true;
|
||||
}
|
||||
// remove rules that do not match any paths
|
||||
// prevents webpack watch mode from firing
|
||||
// due to "removed" paths.
|
||||
return globbySync(glob).length > 0;
|
||||
})
|
||||
.map((glob) => ({
|
||||
from: glob,
|
||||
context: entryDir,
|
||||
|
Reference in New Issue
Block a user