Skip to content

Commit 95b85db

Browse files
committed
extra watch options regex to react-dev-utils
1 parent dc95d18 commit 95b85db

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright (c) 2015-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
'use strict';
9+
10+
const path = require('path');
11+
const escapeStringRegexp = require('escape-string-regexp');
12+
13+
module.exports = function watchOptionsRegex(paths) {
14+
return new RegExp(
15+
`^(?!${escapeStringRegexp(path.join(paths.appSrc, '/'))}).+node_modules`,
16+
'g'
17+
);
18+
};

packages/react-scripts/config/webpack.config.prod.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ module.exports = {
301301
},
302302
mangle: {
303303
safari10: true,
304-
},
304+
},
305305
output: {
306306
comments: false,
307307
// Turned on because emoji and regex is not minified properly using default

packages/react-scripts/config/webpackDevServer.config.js

+2-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
1212
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
13-
const path = require('path');
13+
const watchOptionsRegex = require('react-dev-utils/watchOptionsRegex');
1414
const config = require('./webpack.config.dev');
1515
const paths = require('./paths');
1616

@@ -76,12 +76,7 @@ module.exports = function(proxy, allowedHost) {
7676
// src/node_modules is not ignored to support absolute imports
7777
// https://github.com/facebookincubator/create-react-app/issues/1065
7878
watchOptions: {
79-
ignored: new RegExp(
80-
`^(?!${path
81-
.normalize(paths.appSrc + '/')
82-
.replace(/[\\]+/g, '\\\\')}).+[\\\\/]node_modules[\\\\/]`,
83-
'g'
84-
),
79+
ignored: watchOptionsRegex(paths),
8580
},
8681
// Enable HTTPS if the HTTPS environment variable is set to 'true'
8782
https: protocol === 'https',

0 commit comments

Comments
 (0)