Reputation: 1255
I'm processing multiple js files to build bundles via webpack. However I need to target multiple js files to process across multiple folders, while being able to exclude js files with certain flags in the filename.
I have the following files:
/styles/portal/version2/libraries/jquery.js
/styles/portal/version2/libraries/library.exclude.js
/styles/portal/version2/components/componenta.js
/styles/portal/version2/konstructs/konstructa.js
/styles/portal/version2/konstructs/konstructb.js
/styles/portal/version2/konstructs/konstructc.js
/styles/portal/version2/konstructs/konstructd.disabled.js
/styles/portal/version2/vendors/vendor.js
/styles/portal/version2/vendors/vendor.exclude.js
And this should only grab the following files to bundle:
/styles/portal/version2/libraries/jquery.js
/styles/portal/version2/konstructs/konstructa.js
/styles/portal/version2/konstructs/konstructb.js
/styles/portal/version2/konstructs/konstructc.js
/styles/portal/version2/vendors/vendor.js
So essentially any .js file out of the specific libraries, konstructs, vendor folders and then don't include anything with disabled.js or exclude.js
Upvotes: 1
Views: 343
Reputation:
To get the three directories libraries, konstructs or vendors
that contain
non-disabled
nor exclude
in the file name parts of .js
files would be this:
/^.*?\/(?:libraries|konstructs|vendors)(?=\/)(?:[^\/.]*\/)*(?![^\/]*?\b(?:disabled|exclude)(?=\.)[^\/]*?\.js$)[^\/]*?\.js$/gm
https://regex101.com/r/rTUfeQ/1
Note, use the multi-line modifier if looking at multi-line strings.
If not, no need for it.
Upvotes: 2
Reputation: 37755
You can try exclude option in rule-condition with this pattern
/\.(exclude|disabled)\.js$/
\.
- Matches .
(exclude|disabled)
- Match exclude
or disabled
word\.js
- Matches . followed by js
$
- End of stringUpvotes: 1