Validation of links in HTML files
A plugin for webpack which replaces invalid links in HTML files.
Installation
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.
const ValidateHTMLLinksPlugin = ; moduleexports = plugins:
Options
Name | Type | Default | Description |
---|---|---|---|
types | Array<String> |
['html', 'css', 'js'] |
The types for validation and replacement. Must include html type. |
exclude | Array<String> |
[] |
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:
const ValidateHTMLLinksPlugin = ; moduleexports = plugins: 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.
/interface/js/scripts/popupjs === /interface/js/scripts/popupabc123minjs/interface/js/scripts/popupjs === /interface/js/scripts/popupanotherjs // be careful with dot names!/interface/js/scripts/popupjs !== /interface/js/scripts/popup-anotherjs/interface/js/scripts/popupjs !== /interface/js/scripts/popup-anotherabc123minjs/interface/js/popupjs !== /interface/js/scripts/popupjs/interface/js/scripts/popupjs !== /interface/js/scripts/popupcss
Issues and requests
Feel free to use issues. Pull requests are also always welcome!