feat(webpack): allow watching node_modules (#9781)

This commit is contained in:
Igor Randjelovic
2022-02-18 13:39:28 +01:00
committed by GitHub
parent 61ff7e4762
commit 9c9c831ac0
4 changed files with 22 additions and 0 deletions

View File

@ -636,3 +636,9 @@ exports[`base configuration for ios 1`] = `
}
}"
`;
exports[`base configuration support env.watchNodeModules 1`] = `
Object {
"managedPaths": Array [],
}
`;

View File

@ -22,6 +22,14 @@ describe('base configuration', () => {
});
}
it('support env.watchNodeModules', () => {
init({
ios: true,
watchNodeModules: true,
});
expect(base(new Config()).get('snapshot')).toMatchSnapshot();
});
it('supports dotenv', () => {
const fsSpy = jest.spyOn(fs, 'existsSync');
fsSpy.mockReturnValue(true);

View File

@ -124,6 +124,13 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
],
});
// allow watching node_modules
config.when(env.watchNodeModules, (config) => {
config.set('snapshot', {
managedPaths: [],
});
});
// Set up Terser options
config.optimization.minimizer('TerserPlugin').use(TerserPlugin, [
{

View File

@ -45,6 +45,7 @@ export interface IWebpackEnv {
// misc
replace?: string[] | string;
watchNodeModules?: boolean;
}
interface IChainEntry {