{"_id":"@bestminr/html-loader","_rev":"1-01a00e80139d5afb024ff098eed9f104","name":"@bestminr/html-loader","dist-tags":{"latest":"1.1.1"},"versions":{"1.1.1":{"name":"@bestminr/html-loader","version":"1.1.1","description":"Html loader module for webpack, customized for Bestminr projects","license":"MIT","repository":{"type":"git","url":"git+https://github.com/bestminr/html-loader.git"},"author":{"name":"Chen Min @hikerpig"},"homepage":"https://github.com/bestminr/html-loader","bugs":{"url":"https://github.com/bestminr/html-loader/issues"},"funding":{"type":"opencollective","url":"https://opencollective.com/webpack"},"main":"dist/cjs.js","engines":{"node":">= 8.0.0"},"scripts":{"start":"npm run build -- -w","clean":"del-cli dist","validate:runtime":"es-check es5 \"dist/runtime/**/*.js\"","prebuild":"npm run clean","build":"cross-env NODE_ENV=production babel src -d dist --copy-files","postbuild":"npm run validate:runtime","commitlint":"commitlint --from=master","security":"npm audit","lint:prettier":"prettier --list-different .","lint:js":"eslint --cache .","lint":"npm-run-all -l -p \"lint:**\"","test:only":"cross-env NODE_ENV=test jest","test:watch":"npm run test:only -- --watch","test:coverage":"npm run test:only -- --coverage","pretest":"npm run lint","test":"npm run test:coverage","prepare":"npm run build","release":"standard-version","defaults":"webpack-defaults"},"peerDependencies":{"webpack":"^4.0.0 || ^5.0.0"},"dependencies":{"html-minifier-terser":"^5.0.5","htmlparser2":"^4.1.0","loader-utils":"^2.0.0","parse-srcset":"^1.0.2","schema-utils":"^2.6.6"},"devDependencies":{"@babel/cli":"^7.8.4","@babel/core":"^7.9.0","@babel/preset-env":"^7.9.5","@commitlint/cli":"^8.3.5","@commitlint/config-conventional":"^8.3.4","@webpack-contrib/defaults":"^6.3.0","@webpack-contrib/eslint-config-webpack":"^3.0.0","babel-jest":"^25.4.0","commitlint-azure-pipelines-cli":"^1.0.3","cross-env":"^7.0.2","del":"^5.1.0","del-cli":"^3.0.0","es-check":"^5.1.0","eslint":"^6.8.0","eslint-config-prettier":"^6.11.0","eslint-plugin-import":"^2.20.2","file-loader":"^6.0.0","handlebars":"^4.7.6","husky":"^4.2.5","jest":"^25.4.0","jest-junit":"^10.0.0","lint-staged":"^10.1.7","memfs":"^3.1.2","npm-run-all":"^4.1.5","posthtml":"^0.12.3","posthtml-webp":"^1.5.0","prettier":"^2.0.5","standard-version":"^7.1.0","webpack":"^4.43.0"},"keywords":["webpack","html","loader"],"gitHead":"3f56ddcedb2835ac706f69d020e42f21154baa9e","_id":"@bestminr/html-loader@1.1.1","_nodeVersion":"10.16.2","_npmVersion":"6.14.4","dist":{"integrity":"sha512-s6CnOZqoiHVhlvvhXY0IU0ZjcnfTEvFgovjNWIUrHajFYZM0dH9ixc4E4PLvrMBsap+u5lBVkuMl/Pnr0BQYEg==","shasum":"ee495a1c48b26acf9043eb9578f59cba05dc138a","tarball":"https://registry.npmjs.org/@bestminr/html-loader/-/html-loader-1.1.1.tgz","fileCount":13,"unpackedSize":58826,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJesiiQCRA9TVsSAnZWagAA/vIP/18f5VRkDml+j828mKmk\nG3+nV8OMRdAS9qiwrcRyPtVSUip7mi0agTvCZ5jNdxP+U+OGbBBPrVxH5vLb\no4FV4N0Fn4DBj6wHtvm4wDri8/u698RZeTYHODFc3xpa6thuOTBumiWxDVGC\n7eTE+qBKwI51tvI9D+RzIFHcva++yxrbsQYajfOI87//7SkV7Of6/dBpNAXw\n+WXptYPX8oX/QsAwoN3SV+J3uZ3/AVBGrmEyVX55GuHbe9AG52qglLbEaR/t\nSfRI7CYqKomaw9Ya1leQPHUls+rcpnAehVbDSf2s3X7Mk9sTe6kXuUCQPNKs\nmW0oTTeWygWIy8RcCi3Ab2SMRNori63ZvMCefLfN8pagopvDTtIo+W1fzS4E\nS0sKuHclgdxGFxsIqri8TOBLJmAF125NqpoW4NjEDdbFDDnLa89ZW1p2R7mF\nA8l/hTwr7pvzSKtfJbAUJgU1O+a5bxMU8TKcluB+gZWg6YFV26q2B9p2ILr1\n5s9SQmGt4Rwj6zj1g4A8gLnmv4+9giMZzqQ2l+fg2Z0PoKSUc5mZmSPmYFdm\nb5C4bMzeFw8C49onU4/PzOR5OVMaNPoSov0a2lysIcYnAg4hUHT1VJxq0c5Q\ngcVQltkJgpVhH9D0YWP8A7uBmclZ8QOsadp7eSnX6/wPHR6csXsKLgqZPDU0\nwy8i\r\n=TFV/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD6zODBK2lIgL1KPn1wAVyXpjCCLBJrqTkTMc6epnxrVQIhAOXiWDZs90nUkjWjGlsDwPogu7T+0FpPxvX+lh5KBeMx"}]},"maintainers":[{"name":"imsunhao","email":"imsunhao@vip.163.com"},{"name":"hikerpig","email":"hikerpigwinnie@gmail.com"}],"_npmUser":{"name":"hikerpig","email":"hikerpigwinnie@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/html-loader_1.1.1_1588734095571_0.4911701780372968"},"_hasShrinkwrap":false}},"time":{"created":"2020-05-06T03:01:35.412Z","1.1.1":"2020-05-06T03:01:35.669Z","modified":"2022-04-04T18:33:46.451Z"},"maintainers":[{"name":"imsunhao","email":"imsunhao@vip.163.com"},{"name":"hikerpig","email":"hikerpigwinnie@gmail.com"}],"description":"Html loader module for webpack, customized for Bestminr projects","homepage":"https://github.com/bestminr/html-loader","keywords":["webpack","html","loader"],"repository":{"type":"git","url":"git+https://github.com/bestminr/html-loader.git"},"author":{"name":"Chen Min @hikerpig"},"bugs":{"url":"https://github.com/bestminr/html-loader/issues"},"license":"MIT","readme":"## NOTE: This is a fork of the official webpack-contrib/html-loader, with node engine requirement downgrade to \"node >= 8.0.0\"\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![deps][deps]][deps-url]\n[![tests][tests]][tests-url]\n[![coverage][cover]][cover-url]\n[![chat][chat]][chat-url]\n[![size][size]][size-url]\n\n# html-loader\n\nExports HTML as string. HTML is minimized when the compiler demands.\n\n## Getting Started\n\nTo begin, you'll need to install `html-loader`:\n\n```console\nnpm install --save-dev html-loader\n```\n\nThen add the plugin to your `webpack` config. For example:\n\n**file.js**\n\n```js\nimport html from './file.html';\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n      },\n    ],\n  },\n};\n```\n\n## Options\n\n|                Name                 |        Type         |                   Default                    | Description                                      |\n| :---------------------------------: | :-----------------: | :------------------------------------------: | :----------------------------------------------- |\n|   **[`attributes`](#attributes)**   | `{Boolean\\|Object}` |                    `true`                    | Enables/Disables attributes handling             |\n| **[`preprocessor`](#preprocessor)** |    `{Function}`     |                 `undefined`                  | Allows pre-processing of content before handling |\n|     **[`minimize`](#minimize)**     | `{Boolean\\|Object}` | `true` in production mode, otherwise `false` | Tell `html-loader` to minimize HTML              |\n|     **[`esModule`](#esmodule)**     |     `{Boolean}`     |                   `false`                    | Use ES modules syntax                            |\n\n### `attributes`\n\nType: `Boolean|Object`\nDefault: `true`\n\nBy default every loadable attributes (for example - `<img src=\"image.png\">`) is imported (`const img = require('./image.png')` or `import img from \"./image.png\"\"`).\nYou may need to specify loaders for images in your configuration (recommended `file-loader` or `url-loader`).\n\nSupported tags and attributes:\n\n- the `src` attribute of the `audio` tag\n- the `src` attribute of the `embed` tag\n- the `src` attribute of the `img` tag\n- the `srcset` attribute of the `img` tag\n- the `src` attribute of the `input` tag\n- the `href` attribute of the `link` tag (only for stylesheets)\n- the `data` attribute of the `object` tag\n- the `src` attribute of the `script` tag\n- the `src` attribute of the `source` tag\n- the `srcset` attribute of the `source` tag\n- the `src` attribute of the `track` tag\n- the `poster` attribute of the `video` tag\n- the `src` attribute of the `video` tag\n\n#### `Boolean`\n\nThe `true` value enables processing of all default elements and attributes, the `false` disable processing of all attributes.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n        options: {\n          // Disables attributes processing\n          attributes: false,\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `Object`\n\nAllows you to specify which tags and attributes to process, filter them, filter urls and process sources starts with `/`.\nFor example:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n        options: {\n          attributes: {\n            list: [\n              {\n                tag: 'img',\n                attribute: 'src',\n                type: 'src',\n              },\n              {\n                tag: 'img',\n                attribute: 'srcset',\n                type: 'srcset',\n              },\n              {\n                tag: 'img',\n                attribute: 'data-src',\n                type: 'src',\n              },\n              {\n                tag: 'img',\n                attribute: 'data-srcset',\n                type: 'srcset',\n              },\n              {\n                tag: 'link',\n                attribute: 'href',\n                type: 'src',\n                filter: (tag, attribute, attributes) => {\n                  if (!/stylesheet/i.test(attributes.rel)) {\n                    return false;\n                  }\n\n                  if (\n                    attributes.type &&\n                    attributes.type.trim().toLowerCase() !== 'text/css'\n                  ) {\n                    return false;\n                  }\n\n                  return true;\n                },\n              },\n              // More attributes\n            ],\n            urlFilter: (attribute, value, resourcePath) => {\n              // The `attribute` argument contains a name of the HTML attribute.\n              // The `value` argument contains a value of the HTML attribute.\n              // The `resourcePath` argument contains a path to the loaded HTML file.\n\n              if (/example\\.pdf$/.test(value)) {\n                return false;\n              }\n\n              return true;\n            },\n            root: '.',\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `list`\n\nType: `Array`\nDefault: https://github.com/webpack-contrib/html-loader#attributes\n\nAllows to setup which tags and attributes to process and how, and the ability to filter some of them.\n\nFor example:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n        options: {\n          attributes: {\n            list: [\n              {\n                // Tag name\n                tag: 'img',\n                // Attribute name\n                attribute: 'src',\n                // Type of processing, can be `src` or `scrset`\n                type: 'src',\n              },\n              {\n                // Tag name\n                tag: 'img',\n                // Attribute name\n                attribute: 'srcset',\n                // Type of processing, can be `src` or `scrset`\n                type: 'srcset',\n              },\n              {\n                tag: 'img',\n                attribute: 'data-src',\n                type: 'src',\n              },\n              {\n                tag: 'img',\n                attribute: 'data-srcset',\n                type: 'srcset',\n              },\n              {\n                // Tag name\n                tag: 'link',\n                // Attribute name\n                attribute: 'href',\n                // Type of processing, can be `src` or `scrset`\n                type: 'src',\n                // Allow to filter some attributes\n                filter: (tag, attribute, attributes, resourcePath) => {\n                  // The `tag` argument contains a name of the HTML tag.\n                  // The `attribute` argument contains a name of the HTML attribute.\n                  // The `attributes` argument contains all attributes of the tag.\n                  // The `resourcePath` argument contains a path to the loaded HTML file.\n\n                  if (/my-html\\.html$/.test(resourcePath)) {\n                    return false;\n                  }\n\n                  if (!/stylesheet/i.test(attributes.rel)) {\n                    return false;\n                  }\n\n                  if (\n                    attributes.type &&\n                    attributes.type.trim().toLowerCase() !== 'text/css'\n                  ) {\n                    return false;\n                  }\n\n                  return true;\n                },\n              },\n            ],\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\nIf the tag name is not specified it will process all the tags.\n\n> You can use your custom filter to specify html elements to be processed.\n\nFor example:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n        options: {\n          attributes: {\n            list: [\n              {\n                // Attribute name\n                attribute: 'src',\n                // Type of processing, can be `src` or `scrset`\n                type: 'src',\n                // Allow to filter some attributes (optional)\n                filter: (tag, attribute, attributes, resourcePath) => {\n                  // The `tag` argument contains a name of the HTML tag.\n                  // The `attribute` argument contains a name of the HTML attribute.\n                  // The `attributes` argument contains all attributes of the tag.\n                  // The `resourcePath` argument contains a path to the loaded HTML file.\n\n                  // choose all HTML tags except img tag\n                  return tag.toLowerCase() !== 'img';\n                },\n              },\n            ],\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `urlFilter`\n\nType: `Function`\nDefault: `undefined`\n\nAllow to filter urls. All filtered urls will not be resolved (left in the code as they were written).\nAll non requestable sources (for example `<img src=\"javascript:void(0)\">`) do not handle by default.\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n        options: {\n          attributes: {\n            urlFilter: (attribute, value, resourcePath) => {\n              // The `attribute` argument contains a name of the HTML attribute.\n              // The `value` argument contains a value of the HTML attribute.\n              // The `resourcePath` argument contains a path to the loaded HTML file.\n\n              if (/example\\.pdf$/.test(value)) {\n                return false;\n              }\n\n              return true;\n            },\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `root`\n\nType: `String`\nDefault: `undefined`\n\nFor urls that start with a `/`, the default behavior is to not translate them.\nIf a `root` query parameter is set, however, it will be prepended to the url and then translated.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n        options: {\n          attributes: {\n            root: '.',\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n### `preprocessor`\n\nType: `Function`\nDefault: `undefined`\n\nAllows pre-processing of content before handling.\n\n> ⚠ You should always return valid HTML\n\n**file.hbs**\n\n```hbs\n<div>\n  <p>{{firstname}} {{lastname}}</p>\n  <img src=\"image.png\" alt=\"alt\" />\n<div>\n```\n\n#### `Function`\n\nYou can set the `preprocessor` option as a `Function` instance.\n\n**webpack.config.js**\n\n```js\nconst Handlebars = require('handlebars');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.hbs$/i,\n        loader: 'html-loader',\n        options: {\n          preprocessor: (content, loaderContext) => {\n            let result;\n\n            try {\n              result = Handlebars.compile(content)({\n                firstname: 'Value',\n                lastname: 'OtherValue',\n              });\n            } catch (error) {\n              loaderContext.emitError(error);\n\n              return content;\n            }\n\n            return result;\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\nYou can also set the `preprocessor` option as an asynchronous function instance.\n\nFor example:\n\n**webpack.config.js**\n\n```js\nconst Handlebars = require('handlebars');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.hbs$/i,\n        loader: 'html-loader',\n        options: {\n          preprocessor: async (content, loaderContext) => {\n            let result;\n\n            try {\n              result = await Handlebars.compile(content)({\n                firstname: 'Value',\n                lastname: 'OtherValue',\n              });\n            } catch (error) {\n              await loaderContext.emitError(error);\n\n              return content;\n            }\n\n            return result;\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n### `minimize`\n\nType: `Boolean|Object`\nDefault: `true` in production mode, otherwise `false`\n\nTell `html-loader` to minimize HTML.\n\n#### `Boolean`\n\nThe enabled rules for minimizing by default are the following ones:\n\n- `collapseWhitespace`\n- `conservativeCollapse`\n- `keepClosingSlash`\n- `minifyCSS`\n- `minifyJS`\n- `removeAttributeQuotes`\n- `removeComments`\n- `removeScriptTypeAttributes`\n- `removeStyleTypeAttributes`\n- `useShortDoctype`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n        options: {\n          minimize: true,\n        },\n      },\n    ],\n  },\n};\n```\n\n#### `Object`\n\n**webpack.config.js**\n\nSee [html-minifier-terser](https://github.com/DanielRuf/html-minifier-terser)'s documentation for more information on the available options.\n\nThe rules can be disabled using the following options in your `webpack.conf.js`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n        options: {\n          minimize: {\n            removeComments: false,\n            collapseWhitespace: false,\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n### `esModule`\n\nType: `Boolean`\nDefault: `false`\n\nBy default, `html-loader` generates JS modules that use the CommonJS modules syntax.\nThere are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).\n\nYou can enable a ES module syntax using:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        loader: 'html-loader',\n        options: {\n          esModule: true,\n        },\n      },\n    ],\n  },\n};\n```\n\n## Examples\n\n### CDN\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      { test: /\\.jpg$/, loader: 'file-loader' },\n      { test: /\\.png$/, loader: 'url-loader' },\n    ],\n  },\n  output: {\n    publicPath: 'http://cdn.example.com/[hash]/',\n  },\n};\n```\n\n**file.html**\n\n```html\n<img src=\"image.jpg\" data-src=\"image2x.png\" />\n```\n\n**index.js**\n\n```js\nrequire('html-loader!./file.html');\n\n// => '<img src=\"http://cdn.example.com/49eba9f/a992ca.jpg\" data-src=\"image2x.png\">'\n```\n\n```js\nrequire('html-loader?{\"attributes\":{\"list\":[{\"tag\":\"img\",\"attribute\":\"data-src\",\"type\":\"src\"}]}}!./file.html');\n\n// => '<img src=\"image.jpg\" data-src=\"data:image/png;base64,...\" >'\n```\n\n```js\nrequire('html-loader?{\"attributes\":{\"list\":[{\"tag\":\"img\",\"attribute\":\"src\",\"type\":\"src\"},{\"tag\":\"img\",\"attribute\":\"data-src\",\"type\":\"src\"}]}}!./file.html');\n\n// => '<img src=\"http://cdn.example.com/49eba9f/a992ca.jpg\" data-src=\"data:image/png;base64,...\" >'\n```\n\n```js\nrequire('html-loader?-attributes!./file.html');\n\n// => '<img src=\"image.jpg\"  data-src=\"image2x.png\" >'\n```\n\n> :warning: `-attributes` sets `attributes: false`.\n\n### Process `script` and `link` tags\n\n**script.file.js**\n\n```js\nconsole.log(document);\n```\n\n**style.file.css**\n\n```css\na {\n  color: red;\n}\n```\n\n**file.html**\n\n```html\n<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"UTF-8\" />\n    <title>Title of the document</title>\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"./style.file.css\" />\n  </head>\n  <body>\n    Content of the document......\n    <script src=\"./script.file.js\"></script>\n  </body>\n</html>\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        use: ['file-loader?name=[name].[ext]', 'extract-loader', 'html-loader'],\n      },\n      {\n        test: /\\.js$/i,\n        exclude: /\\.file.js$/i,\n        loader: 'babel-loader',\n      },\n      {\n        test: /\\.file.js$/i,\n        loader: 'file-loader',\n      },\n      {\n        test: /\\.css$/i,\n        exclude: /\\.file.css$/i,\n        loader: 'css-loader',\n      },\n      {\n        test: /\\.file.css$/i,\n        loader: 'file-loader',\n      },\n    ],\n  },\n};\n```\n\n### 'Root-relative' URLs\n\nWith the same configuration as in the CDN example:\n\n**file.html**\n\n```html\n<img src=\"/image.jpg\" />\n```\n\n**scripts.js**\n\n```js\nrequire('html-loader!./file.html');\n\n// => '<img src=\"/image.jpg\">'\n```\n\n**other-scripts.js**\n\n```js\nrequire('html-loader?{\"attributes\":{\"root\":\".\"}}!./file.html');\n\n// => '<img src=\"http://cdn.example.com/49eba9f/a992ca.jpg\">'\n```\n\n### Templating\n\nYou can use any template system. Below is an example for [handlebars](https://handlebarsjs.com/).\n\n**file.hbs**\n\n```hbs\n<div>\n  <p>{{firstname}} {{lastname}}</p>\n  <img src=\"image.png\" alt=\"alt\" />\n<div>\n```\n\n**webpack.config.js**\n\n```js\nconst Handlebars = require('handlebars');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.hbs$/i,\n        loader: 'html-loader',\n        options: {\n          preprocessor: (content, loaderContext) => {\n            let result;\n\n            try {\n              result = Handlebars.compile(content)({\n                firstname: 'Value',\n                lastname: 'OtherValue',\n              });\n            } catch (error) {\n              loaderContext.emitError(error);\n\n              return content;\n            }\n\n            return result;\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n### PostHTML\n\nYou can use [PostHTML](https://github.com/posthtml/posthtml) without any additional loaders.\n\n**file.html**\n\n```html\n<img src=\"image.jpg\" />\n```\n\n**webpack.config.js**\n\n```js\nconst posthtml = require('posthtml');\nconst posthtmlWebp = require('posthtml-webp');\n\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.hbs$/i,\n        loader: 'html-loader',\n        options: {\n          preprocessor: (content, loaderContext) => {\n            let result;\n\n            try {\n              result = posthtml().use(plugin).process(content, { sync: true });\n            } catch (error) {\n              loaderContext.emitError(error);\n\n              return content;\n            }\n\n            return result.html;\n          },\n        },\n      },\n    ],\n  },\n};\n```\n\n### Export into HTML files\n\nA very common scenario is exporting the HTML into their own _.html_ file, to\nserve them directly instead of injecting with javascript. This can be achieved\nwith a combination of 3 loaders:\n\n- [file-loader](https://github.com/webpack/file-loader)\n- [extract-loader](https://github.com/peerigon/extract-loader)\n- html-loader\n\nThe html-loader will parse the URLs, require the images and everything you\nexpect. The extract loader will parse the javascript back into a proper html\nfile, ensuring images are required and point to proper path, and the file loader\nwill write the _.html_ file for you. Example:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.html$/i,\n        use: ['file-loader?name=[name].[ext]', 'extract-loader', 'html-loader'],\n      },\n    ],\n  },\n};\n```\n\n## Contributing\n\nPlease take a moment to read our contributing guidelines if you haven't yet done so.\n\n[CONTRIBUTING](./.github/CONTRIBUTING.md)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/html-loader.svg\n[npm-url]: https://npmjs.com/package/html-loader\n[node]: https://img.shields.io/node/v/html-loader.svg\n[node-url]: https://nodejs.org\n[deps]: https://david-dm.org/webpack-contrib/html-loader.svg\n[deps-url]: https://david-dm.org/webpack-contrib/html-loader\n[tests]: https://github.com/webpack-contrib/html-loader/workflows/html-loader/badge.svg\n[tests-url]: https://github.com/webpack-contrib/html-loader/actions\n[cover]: https://codecov.io/gh/webpack-contrib/html-loader/branch/master/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack-contrib/html-loader\n[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg\n[chat-url]: https://gitter.im/webpack/webpack\n[size]: https://packagephobia.now.sh/badge?p=html-loader\n[size-url]: https://packagephobia.now.sh/result?p=html-loader\n","readmeFilename":"README.md"}