I am using webpack which takes regular expressions to feed files into loaders. I want to exclude test files from build, and the test files end with .test.js
. So, I am looking for a regular expression that would match index.js
but not index.test.js
.
I tried to use a negative lookback assertion with
/(?<!\.test)\.js$/
but it says that the expression is invalid.
SyntaxError: Invalid regular expression: /(?<!\.test)\.js$/: Invalid group
example files names:
index.js // <-- should match
index.test.js // <-- should not match
component.js // <-- should match
component.test.js // <-- should not match
function (path) { return path.endsWith('.js') && !path.endsWith('test.js')}
I could be mixing this up with some other bundler though. – Germicide