Skip to content

Commit

Permalink
Watch for changes in src/**/node_modules (#3230)
Browse files Browse the repository at this point in the history
* Allow the dev server to watch for changes in src/node_modules

* fix eslint error

* fix broken regex

* handle trailing slash edge case for file paths

Closes #2760
Fixes #3223
  • Loading branch information
xjlim authored and Timer committed Oct 3, 2017
1 parent c003583 commit 1e98d0f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
10 changes: 7 additions & 3 deletions packages/react-dev-utils/getProcessForPort.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function getProcessCommand(processId, processDirectory) {
execOptions
);

command = command.replace(/\n$/, '')
command = command.replace(/\n$/, '');

if (isProcessAReactApp(command)) {
const packageName = getPackageNameInDirectory(processDirectory);
Expand All @@ -68,8 +68,12 @@ function getProcessForPort(port) {
var processId = getProcessIdOnPort(port);
var directory = getDirectoryOfProcessById(processId);
var command = getProcessCommand(processId, directory);
return chalk.cyan(command) + chalk.grey(' (pid ' + processId + ')\n') +
chalk.blue(' in ') + chalk.cyan(directory);
return (
chalk.cyan(command) +
chalk.grey(' (pid ' + processId + ')\n') +
chalk.blue(' in ') +
chalk.cyan(directory)
);
} catch (e) {
return null;
}
Expand Down
8 changes: 7 additions & 1 deletion packages/react-scripts/config/webpackDevServer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
const path = require('path');
const config = require('./webpack.config.dev');
const paths = require('./paths');

Expand Down Expand Up @@ -72,8 +73,13 @@ module.exports = function(proxy, allowedHost) {
quiet: true,
// Reportedly, this avoids CPU overload on some systems.
// https://github.com/facebookincubator/create-react-app/issues/293
// src/node_modules is not ignored to support absolute imports
// https://github.com/facebookincubator/create-react-app/issues/1065
watchOptions: {
ignored: /node_modules/,
ignored: new RegExp(
`^(?!${path.normalize(paths.appSrc + '/')}).+[\\/]node_modules[\\/]`,
'g'
),
},
// Enable HTTPS if the HTTPS environment variable is set to 'true'
https: protocol === 'https',
Expand Down

0 comments on commit 1e98d0f

Please sign in to comment.