brunch / brunch

:fork_and_knife: Web applications made easy. Since 2011.
https://brunch.io
MIT License
6.81k stars 435 forks source link

Can the watcher be made to ignore package.json? #1827

Closed ventaur closed 2 years ago

ventaur commented 5 years ago

Description

I have a poorly-behaving library (Cordova) that is constantly updating package.json even when there is nothing actually changed. That, in turn, is making Brunch's watcher rebuild, which then makes this library reload the browser, update package.json, and start the infinite cycle all over again. As it is now, I have to keep the Brunch watcher off and manually rebuild after every change I want to try via Cordova's serve command for the browser.

Here's the issue filed with Cordova for reference.

This brings up a possible (though somewhat rare) use case for having Brunch's watcher ignore changes to the package.json file. I tried setting watcher.ignored in the config to /package\.json/ to no effect. Is it worth it to have the option to ignore changes to package.json with respect to the watcher? Did I miss a possible config setting to achieve this?

Expected behavior

It could be useful to have an option to instruct the watcher to ignore package.json file changes.

Actual behavior

The following config setting didn't work as expected. Most other Brunch conventions/defaults are overridable.

watcher: { ignored: /package\.json/ }

Environment

  1. Brunch: 2.10.17
  2. Node.js: 8.11.2
  3. NPM: 6.0.1
  4. Operating system: Win 10
  5. Code editor: VS Code

package.json contents

...
  "dependencies": {
    "babel-polyfill": "^6.26.0",
    "cordova-android": "^7.1.1",
    "cordova-browser": "^5.0.4",
    "cordova-ios": "4.5.5",
    "cordova-plugin-network-information": "~1.2.0",
    "cordova-plugin-statusbar": "~2.1.2",
    "cordova-plugin-whitelist": "~1.2.1",
    "font-awesome": "^4.7.0",
    "framework7": "^3.3.0",
    "lodash-es": "^4.17.11"
  },
  "devDependencies": {
    "archiver": "^3.0.0",
    "autoprefixer": "^8.5.0",
    "babel-brunch": "^6.1.1",
    "babel-cli": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "brunch": "^2.10.17",
    "clean-css-brunch": "^2.10.0",
    "copycat-brunch": "^1.1.0",
    "cross-env": "^5.1.5",
    "mkdirp": "^0.5.1",
    "postcss-brunch": "^2.10.1",
    "replace-in-file": "^3.4.2",
    "sass-brunch": "^2.10.7",
    "uglify-js-brunch": "^2.10.0",
    "versiony": "^2.0.1"
  },
  "cordova": {
    "platforms": [
      "ios",
      "android",
      "browser"
    ],
    "plugins": {
      "cordova-plugin-network-information": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {}
    }
  }

brunch config contents

const autoprefixer = require('autoprefixer');
module.exports = {
    files: {
        javascripts: {
            joinTo: {
                'js/app.js': /^app/,
                'js/vendor.js': /^(?!app)/
            }
        },
        stylesheets: {
            joinTo: {
                'css/app.css': /^app/,
                'css/vendor.css': /^(?!app)/
            }
        }
    },

    paths: {
        public: 'www'
    },

    plugins: {
        babel: { presets: ['env'] },
        copycat: {
            onlyChanged: true,
            'fonts': [ 'node_modules/font-awesome/fonts' ],
        },
        sass: { precision: 8 },
        postcss: {
            processors: [
                autoprefixer(['last 8 versions']),
            ]
        }
    },

    npm: {
        enabled: true,
        compilers: ['babel-brunch'],
        styles: {
            framework7: ['css/framework7.min.css']
        }
    }
};

Other useful files, when present (log, bower.json etc.)

n/a