Search code examples
command-line-interfacewatchrollup

How to make the rollup CLI watch.include multiple files or directories?


I'm starting a rollup process with watching using:

npx rollup -c rollup.config.js --watch --watch.include=js/**

But now I want to add a second directory that I want to watch as well: styles/**

How chan I change the command so that both the js and styles directories are being watched?


Solution

  • edit: this no longer seems to work with a newer version of rollup. Instead I now simply add

    {
        watch: {
            include: ["js/**", "styles/**"]
        }
    }
    

    to the rollup config.


    old answer:

    If you are configuring your watcher from your rollup.config.json you could simply use an array for the watch.include property. But on the CLI this is not an option.

    You could, however, change the glob pattern in the command so that it contains multiple patterns (see this answer).

    Then your command would become:

    npx rollup -c rollup.config.js --watch --watch.include=*(js/**|styles/**)