https://github.com/amaimersion/validate-html-links-webpack-plugin
A plugin for webpack which replaces invalid links in HTML files.
https://github.com/amaimersion/validate-html-links-webpack-plugin
build-automation plugin plugins validate validate-html validate-html-links validate-jade validate-jade-links validate-pug validate-pug-links webpack webpack-plugin
Last synced: 4 months ago
JSON representation
A plugin for webpack which replaces invalid links in HTML files.
- Host: GitHub
- URL: https://github.com/amaimersion/validate-html-links-webpack-plugin
- Owner: Amaimersion
- License: mit
- Archived: true
- Created: 2018-05-31T16:08:48.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-01T14:35:55.000Z (almost 7 years ago)
- Last Synced: 2024-03-29T10:47:49.990Z (about 1 year ago)
- Topics: build-automation, plugin, plugins, validate, validate-html, validate-html-links, validate-jade, validate-jade-links, validate-pug, validate-pug-links, webpack, webpack-plugin
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/validate-html-links-webpack-plugin
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Validation of links in HTML files
A plugin for webpack which replaces invalid links in HTML files.## Installation
```javascript
npm install validate-html-links-webpack-plugin --save-dev
```## Usage
The plugin replaces invalid names of resource links with correct names relative to project path. This is especially useful when files contains chunkhash and there is no other way to change this at compile time.
```javascript
const ValidateHTMLLinksPlugin = require('validate-html-links-webpack-plugin');module.exports = {
plugins: [
new ValidateHTMLLinksPlugin()
]
}
```## Options
| Name | Type | Default | Description |
| :---------: |:---------------:| :------------------------:|:------------|
| types | `Array` | `['html', 'css', 'js']` | The types for validation and replacement. Must include `html` type. |
| exclude | `Array` | `[]` | The files that will not be processed. If you include `html` file, then the entire file will be skipped.|
| output | `Boolean` |`true` | Show in the compilation output what has been changed. |#### Example how to set these options:
```javascript
const ValidateHTMLLinksPlugin = require('validate-html-links-webpack-plugin');module.exports = {
plugins: [
new ValidateHTMLLinksPlugin({
types: ['html', 'js'],
exclude: ['/interface/js/scripts/popup.js'],
output: false
})
]
}
```## Validation Examples
Be aware that links compares by (a-z | A-Z | 0-9 | .). If comparable link has the same path and difference only in the `([[:alnum:]]|\.)`, then it will be the same link.
In short, match conditions:
- same path;
- difference of name only in range of a-z, A-Z, 0-9 or `'.'`;
- same type.```javascript
/interface/js/scripts/popup.js === /interface/js/scripts/popup.abc123.min.js
/interface/js/scripts/popup.js === /interface/js/scripts/popup.another.js // be careful with dot names!
/interface/js/scripts/popup.js !== /interface/js/scripts/popup-another.js
/interface/js/scripts/popup.js !== /interface/js/scripts/popup-another.abc123.min.js
/interface/js/popup.js !== /interface/js/scripts/popup.js
/interface/js/scripts/popup.js !== /interface/js/scripts/popup.css
```## Issues and requests
Feel free to use [issues](https://github.com/Amaimersion/validate-html-links-webpack-plugin/issues). [Pull requests](https://github.com/Amaimersion/validate-html-links-webpack-plugin/pulls) are also always welcome!