UNPKG

946 Bapplication/x-shView Raw
1#!/bin/bash
2# Should be used until https://github.com/webpack/watchpack/pull/23 is merged and available in npm
3# See https://github.com/webpack/watchpack/issues/2#issuecomment-135204573 for more info
4
5# Ensure we have npm
6if ! hash npm 2>/dev/null; then
7 echo 'No NPM installed!'
8 exit 1
9fi
10
11# npm@3 uses flat tree structure so account for that
12if npm -v 2>/dev/null | grep -q "^2."; then
13 FILEPATH="node_modules/webpack/node_modules/watchpack/lib/DirectoryWatcher.js"
14else
15 FILEPATH="node_modules/watchpack/lib/DirectoryWatcher.js"
16fi
17
18INSERTION_POINT_BEFORE="followSymlinks: false,"
19MISSING_OPTION="ignored: /node_modules/,"
20
21if ! cat ${FILEPATH} 2>/dev/null | grep -q "${MISSING_OPTION}"; then
22 echo 'Fixing webpack watch (polling) slowness with a manual hack. See https://github.com/webpack/watchpack/pull/23 for more info.'
23 sed -i -e 's|'"${INSERTION_POINT_BEFORE}"'|'"${INSERTION_POINT_BEFORE} ${MISSING_OPTION}"'|' "${FILEPATH}"
24fi