Laravel mix watch ignore multiple folders using watchOptions

758 Views Asked by At

Using Laravel Mix 6 trying to disable changes to /resources/view from rebuilding resources.

ignored (anymatch-compatible definition) Defines files/paths to be ignored. The whole relative or absolute path is tested, not just filename. If a function with two arguments is provided, it gets called twice per path - once with a single argument (the path), second time with two arguments (the path and the fs.Stats object of that path).

mix.webpackConfig({
    watchOptions: { ignored: ['/node_modules/', '/resources/views/'] }
});

If I try with function:

mix.webpackConfig({
    watchOptions: {
        ignored: (path) => ["node_modules", "resources/views"].some(s => path.includes(s))
    }
});

[webpack-cli] Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.

  • configuration.watchOptions.ignored should be one of these: [non-empty string, ...] | RegExp | non-empty string -> Ignore some files from watching (glob pattern or regexp). Details:
    • configuration.watchOptions.ignored should be an array: [non-empty string, ...]
    • configuration.watchOptions.ignored should be an instance of RegExp.
    • configuration.watchOptions.ignored should be a non-empty string. -> A single glob pattern for files that should be ignored from watching.
0

There are 0 best solutions below