-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add a warning note for common errors when specifying rules #2376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
When specifying a test in `module.rules`, webpack accepts either a regex or string. However it's easy to mistakenly qoute the regex which will cause webpack to not use the specified loader. I added this warning to help newcomers like me who might stumbled into this situation save themselves frustrations and wasted time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a typo
src/content/concepts/index.md
Outdated
@@ -114,6 +114,8 @@ The configuration above has defined a `rules` property for a single module with | |||
|
|||
W> It is important to remember that when defining rules in your webpack config, you are defining them under `module.rules` and not `rules`. For your benefit, webpack will warn you if this is done incorrectly. | |||
|
|||
W> Keep in mind that when using regex to match files, you may not qoute it. i.e `\/.txt$/` is not the same as `'\/.txt$'`/ `"/\.txt$/"`. The former instructs webpack to match any file that ends with .txt and the later instructs webpack to match a single file with an absolute path '.txt'; this is likely not your intention. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
quote
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean /\.txt$/
instead of \/.txt$/
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and I don't think any of you string variations will match anything at all, so I would omit the part about '.txt'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@asapach you're right
@montogeek, typos fixed thanks |
@@ -114,6 +114,8 @@ The configuration above has defined a `rules` property for a single module with | |||
|
|||
W> It is important to remember that when defining rules in your webpack config, you are defining them under `module.rules` and not `rules`. For your benefit, webpack will warn you if this is done incorrectly. | |||
|
|||
W> Keep in mind that when using regex to match files, you may not quote it. i.e `/\.txt$/` is not the same as `'/\.txt$/'`/ `"/\.txt$/"`. The former instructs webpack to match any file that ends with .txt and the later instructs webpack to match a single file with an absolute path '.txt'; this is likely not your intention. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on one hand this is regex knowledge related warning, on the other it may be useful to users. i am not voting for this and also not against it. If you are good with this pls merge @montogeek
Thanks! |
When specifying a test in
module.rules
, webpack accepts either a regex or string. However it's easy to mistakenly qoute the regex which will cause webpack to not use the specified loader. I added this warning to help newcomers like me who might stumbled into this situation save themselves frustrations and wasted time.