Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tizmagik/check-filename-webpack-plugin
Check Filename - Webpack Plugin
https://github.com/tizmagik/check-filename-webpack-plugin
Last synced: about 1 month ago
JSON representation
Check Filename - Webpack Plugin
- Host: GitHub
- URL: https://github.com/tizmagik/check-filename-webpack-plugin
- Owner: tizmagik
- License: mit
- Created: 2016-08-04T02:58:02.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-04T03:19:59.000Z (over 8 years ago)
- Last Synced: 2024-10-11T09:21:57.790Z (about 1 month ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Check Filename - Webpack Plugin
This Webpack plugin allows you to define a regex to test filename imports and requires against. If a regex matches, it will call the function specified to generate an error string to throw during compilation.
The error looks something like:
> ERROR in ./test/test.js
Module not found: Module load aborted. Only .js extensions allowed, do not use .jsx extensions.
For: /Users/workspace/project/src/Component.jsxGiven the following config:
```js
{
regex: /\.jsx$/,
error: pathName => `Module load aborted. Only .js extensions allowed, do not use .jsx extensions.\n\tFor: ${pathName}`
}
```> NOTE: `error` could also just be a literal string.
# Install
```bash
npm install --save-dev case-sensitive-paths-webpack-plugin
```# Usage
```js
import CheckFilenamePlugin from 'case-sensitive-paths-webpack-plugin';const webpackConfig = {
plugins: [
new CheckFilenamePlugin({
regex: /\.jsx$/,
error: pathName => `Module load aborted. Only .js extensions allowed, do not use .jsx extensions.\n For: ${pathName}`
})
// other plugins ...
]
// other webpack config ...
}
```## Demo
Check the [/demo](demo) directory for a working example of the plugin in action, with tests demonstrating the effect of the plugin. See [/demo/README.md](demo/README.md) for more information.
## Thanks & Credit
Thanks mostly to [Michael Pratt](https://github.com/Urthen) who wrote [case-sensitive-paths-webpack-plugin](https://github.com/Urthen/case-sensitive-paths-webpack-plugin) which this plugin is based mostly off of.