html-loader
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -8,15 +8,11 @@ "use strict"; | ||
var _parse = _interopRequireDefault(require("parse5")); | ||
var _parse = require("parse5"); | ||
var _utils = require("../utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = options => function process(html) { | ||
const sources = []; | ||
const document = _parse.default.parse(html, { | ||
const document = (0, _parse.parse)(html, { | ||
sourceCodeLocationInfo: true | ||
}); | ||
let needIgnore = false; | ||
@@ -23,0 +19,0 @@ (0, _utils.traverse)(document, node => { |
@@ -966,4 +966,6 @@ "use strict"; | ||
} | ||
} | ||
} // Replaces "<script>" or "</script>" to "<" + "script>" or "<" + "/script>". | ||
code = code.replace(/<(\/?script)/g, (_, s) => `<" + "${s}`); | ||
return `// Module\n${replacersCode}var code = ${code};\n`; | ||
@@ -970,0 +972,0 @@ } |
{ | ||
"name": "html-loader", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Html loader module for webpack", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">= 12.13.0" | ||
"node": ">= 14.15.0" | ||
}, | ||
@@ -46,33 +46,33 @@ "scripts": { | ||
"dependencies": { | ||
"html-minifier-terser": "^6.0.2", | ||
"parse5": "^6.0.1" | ||
"html-minifier-terser": "^6.1.0", | ||
"parse5": "^7.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.16.7", | ||
"@babel/core": "^7.16.7", | ||
"@babel/preset-env": "^7.16.7", | ||
"@commitlint/cli": "^14.1.0", | ||
"@commitlint/config-conventional": "^14.1.0", | ||
"@babel/cli": "^7.17.10", | ||
"@babel/core": "^7.18.2", | ||
"@babel/preset-env": "^7.18.2", | ||
"@commitlint/cli": "^17.0.2", | ||
"@commitlint/config-conventional": "^17.0.2", | ||
"@webpack-contrib/eslint-config-webpack": "^3.0.0", | ||
"babel-jest": "^27.4.5", | ||
"babel-jest": "^28.1.1", | ||
"cross-env": "^7.0.3", | ||
"del": "^6.0.0", | ||
"del": "^6.1.1", | ||
"del-cli": "^4.0.0", | ||
"es-check": "^6.1.1", | ||
"eslint": "^8.6.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.25.4", | ||
"es-check": "^6.2.1", | ||
"eslint": "^8.16.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"handlebars": "^4.7.7", | ||
"html-webpack-plugin": "^5.3.2", | ||
"husky": "^7.0.0", | ||
"jest": "^27.4.5", | ||
"lint-staged": "^11.0.0", | ||
"memfs": "^3.4.1", | ||
"husky": "^8.0.1", | ||
"jest": "^28.1.1", | ||
"lint-staged": "^13.0.1", | ||
"memfs": "^3.4.4", | ||
"npm-run-all": "^4.1.5", | ||
"posthtml": "^0.16.4", | ||
"posthtml-webp": "^2.1.0", | ||
"prettier": "^2.5.1", | ||
"standard-version": "^9.3.0", | ||
"posthtml": "^0.16.6", | ||
"posthtml-webp": "^2.2.0", | ||
"prettier": "^2.6.2", | ||
"standard-version": "^9.5.0", | ||
"unescape-unicode": "^0.2.0", | ||
"webpack": "^5.65.0" | ||
"webpack": "^5.73.0" | ||
}, | ||
@@ -79,0 +79,0 @@ "keywords": [ |
134
README.md
<div align="center"> | ||
<img width="200" height="200" src="https://worldvectorlogo.com/logos/html5.svg" alt="html-loader"> | ||
<img width="200" height="200" src="https://www.w3.org/html/logo/downloads/HTML5_Logo.svg" alt="html-loader"> | ||
<a href="https://github.com/webpack/webpack"> | ||
@@ -10,3 +10,2 @@ <img width="200" height="200" vspace="" hspace="25" src="https://webpack.js.org/assets/icon-square-big.svg" alt="webpack"> | ||
[![node][node]][node-url] | ||
[![deps][deps]][deps-url] | ||
[![tests][tests]][tests-url] | ||
@@ -29,2 +28,14 @@ [![coverage][cover]][cover-url] | ||
or | ||
```console | ||
yarn add -D html-loader | ||
``` | ||
or | ||
```console | ||
pnpm add -D html-loader | ||
``` | ||
Then add the plugin to your `webpack` config. For example: | ||
@@ -55,12 +66,34 @@ | ||
| Name | Type | Default | Description | | ||
| :---------------------------------: | :-----------------: | :------------------------------------------: | :----------------------------------------------- | | ||
| **[`sources`](#sources)** | `{Boolean\|Object}` | `true` | Enables/Disables sources handling | | ||
| **[`preprocessor`](#preprocessor)** | `{Function}` | `undefined` | Allows pre-processing of content before handling | | ||
| **[`minimize`](#minimize)** | `{Boolean\|Object}` | `true` in production mode, otherwise `false` | Tell `html-loader` to minimize HTML | | ||
| **[`esModule`](#esmodule)** | `{Boolean}` | `true` | Enable/disable ES modules syntax | | ||
- **[`sources`](#sources)** | ||
- **[`preprocessor`](#preprocessor)** | ||
- **[`minimize`](#minimize)** | ||
- **[`esModule`](#esmodule)** | ||
### `sources` | ||
Type: `Boolean|Object` | ||
Type: | ||
```ts | ||
type sources = | ||
| boolean | ||
| { | ||
list?: Array<{ | ||
tag?: string; | ||
attribute?: string; | ||
type?: string; | ||
filter?: ( | ||
tag: string, | ||
attribute: string, | ||
attributes: string, | ||
resourcePath: string | ||
) => boolean; | ||
}>; | ||
urlFilter?: ( | ||
attribute: string, | ||
value: string, | ||
resourcePath: string | ||
) => boolean; | ||
}; | ||
``` | ||
Default: `true` | ||
@@ -96,3 +129,3 @@ | ||
#### `Boolean` | ||
#### `boolean` | ||
@@ -120,3 +153,3 @@ The `true` value enables processing of all default elements and attributes, the `false` disable processing of all attributes. | ||
#### `Object` | ||
#### `object` | ||
@@ -173,3 +206,18 @@ Allows you to specify which tags and attributes to process, filter them, filter urls and process sources starts with `/`. | ||
Type: `Array` | ||
Type: | ||
```ts | ||
type list = Array<{ | ||
tag?: string; | ||
attribute?: string; | ||
type?: string; | ||
filter?: ( | ||
tag: string, | ||
attribute: string, | ||
attributes: string, | ||
resourcePath: string | ||
) => boolean; | ||
}>; | ||
``` | ||
Default: [supported tags and attributes](#sources). | ||
@@ -363,3 +411,12 @@ | ||
Type: `Function` | ||
Type: | ||
```ts | ||
type urlFilter = ( | ||
attribute: string, | ||
value: string, | ||
resourcePath: string | ||
) => boolean; | ||
``` | ||
Default: `undefined` | ||
@@ -400,3 +457,11 @@ | ||
Type: `Function` | ||
Type: | ||
```ts | ||
type preprocessor = ( | ||
content: string | Buffer, | ||
loaderContext: LoaderContext | ||
) => HTMLElement; | ||
``` | ||
Default: `undefined` | ||
@@ -417,5 +482,5 @@ | ||
#### `Function` | ||
#### `function` | ||
You can set the `preprocessor` option as a `Function` instance. | ||
You can set the `preprocessor` option as a `function` instance. | ||
@@ -498,3 +563,21 @@ **webpack.config.js** | ||
Type: `Boolean|Object` | ||
Type: | ||
```ts | ||
type minimize = | ||
| boolean | ||
| { | ||
caseSensitive?: boolean; | ||
collapseWhitespace?: boolean; | ||
conservativeCollapse?: boolean; | ||
keepClosingSlash?: boolean; | ||
minifyCSS?: boolean; | ||
minifyJS?: boolean; | ||
removeComments?: boolean; | ||
removeRedundantAttributes?: boolean; | ||
removeScriptTypeAttributes?: boolean; | ||
removeStyleLinkTypeAttributes?: boolean; | ||
}; | ||
``` | ||
Default: `true` in production mode, otherwise `false` | ||
@@ -504,3 +587,3 @@ | ||
#### `Boolean` | ||
#### `boolean` | ||
@@ -542,3 +625,3 @@ The enabled rules for minimizing by default are the following ones: | ||
#### `Object` | ||
#### `object` | ||
@@ -600,3 +683,8 @@ **webpack.config.js** | ||
Type: `Boolean` | ||
Type: | ||
```ts | ||
type esModule = boolean; | ||
``` | ||
Default: `true` | ||
@@ -791,3 +879,3 @@ | ||
test: /\.html$/i, | ||
use: ["extract-loader", "html-loader"], | ||
use: ["html-loader"], | ||
}, | ||
@@ -942,3 +1030,3 @@ { | ||
test: /\.html$/i, | ||
use: ["extract-loader", "html-loader"], | ||
use: ["html-loader"], | ||
}, | ||
@@ -964,4 +1052,2 @@ ], | ||
[node-url]: https://nodejs.org | ||
[deps]: https://david-dm.org/webpack-contrib/html-loader.svg | ||
[deps-url]: https://david-dm.org/webpack-contrib/html-loader | ||
[tests]: https://github.com/webpack-contrib/html-loader/workflows/html-loader/badge.svg | ||
@@ -968,0 +1054,0 @@ [tests-url]: https://github.com/webpack-contrib/html-loader/actions |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69833
1045
+ Addedentities@4.5.0(transitive)
+ Addedparse5@7.1.2(transitive)
- Removedparse5@6.0.1(transitive)
Updatedhtml-minifier-terser@^6.1.0
Updatedparse5@^7.0.0