{"id":18389563,"url":"https://github.com/anseki/htmlclean-loader","last_synced_at":"2025-04-12T06:29:48.324Z","repository":{"id":57267941,"uuid":"75329454","full_name":"anseki/htmlclean-loader","owner":"anseki","description":"htmlclean loader module for webpack - Simple and safety HTML/SVG cleaner to minify without changing its structure.","archived":false,"fork":false,"pushed_at":"2023-01-09T22:16:12.000Z","size":86,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T16:40:42.304Z","etag":null,"topics":["clean","comment","compress","html","javascript","lightweight","linebreak","loader","minify","svg","webpack","webpack-configuration","whitespace"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anseki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-01T20:20:56.000Z","updated_at":"2023-01-09T22:10:51.000Z","dependencies_parsed_at":"2023-02-08T14:46:12.890Z","dependency_job_id":null,"html_url":"https://github.com/anseki/htmlclean-loader","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fhtmlclean-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fhtmlclean-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fhtmlclean-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anseki%2Fhtmlclean-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anseki","download_url":"https://codeload.github.com/anseki/htmlclean-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248528715,"owners_count":21119361,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clean","comment","compress","html","javascript","lightweight","linebreak","loader","minify","svg","webpack","webpack-configuration","whitespace"],"created_at":"2024-11-06T01:43:44.822Z","updated_at":"2025-04-12T06:29:48.292Z","avatar_url":"https://github.com/anseki.png","language":"JavaScript","readme":"# htmlclean-loader\n\n[![npm](https://img.shields.io/npm/v/htmlclean-loader.svg)](https://www.npmjs.com/package/htmlclean-loader) [![GitHub issues](https://img.shields.io/github/issues/anseki/htmlclean-loader.svg)](https://github.com/anseki/htmlclean-loader/issues) [![David](https://img.shields.io/david/anseki/htmlclean-loader.svg)](package.json) [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\n[htmlclean](https://github.com/anseki/htmlclean) loader module for [webpack](https://webpack.js.org/).\n\n* [Grunt](http://gruntjs.com/) plugin: [grunt-htmlclean](https://github.com/anseki/grunt-htmlclean)\n* [gulp](http://gulpjs.com/) plugin: [gulp-htmlclean](https://github.com/anseki/gulp-htmlclean)\n\n**If you want to just clean files, [Command Line Tool](https://github.com/anseki/htmlclean-cli) is easy way.**\n\nSimple and safety HTML/SVG cleaner to minify without changing its structure.  \nSee [htmlclean](https://github.com/anseki/htmlclean) for options and more information about htmlclean.\n\n## Installation\n\n```\nnpm install --save-dev htmlclean-loader htmlclean\n```\n\n## Usage\n\nDocumentation:\n\n- [Loaders](https://webpack.js.org/concepts/loaders/)\n- [Using loaders](http://webpack.github.io/docs/using-loaders.html) (for webpack v1)\n\nFor example:\n\n```js\n// app.js\nvar headerHtml = require('./header.html');\ndocument.getElementById('header').innerHTML = headerHtml;\n```\n\n```js\n// webpack.config.js\nmodule.exports = {\n  entry: './app.js',\n  output: {\n    filename: 'bundle.js'\n  },\n  module: {\n    rules: [{\n      test: /\\.html$/,\n      loader: 'htmlclean-loader'\n    }]\n  }\n};\n```\n\n## Options\n\nYou can specify options via query parameters or an `options` (or `htmlcleanLoader` for webpack v1) object in webpack configuration.\n\nFor example:\n\n```js\n// webpack.config.js\nmodule.exports = {\n  // ...\n  module: {\n    rules: [{\n      test: /\\.html$/,\n      loader: 'htmlclean-loader',\n      options: {\n        protect: /\u003c\\!--%fooTemplate\\b.*?%--\u003e/g,\n        edit: function(html) {\n          return html.replace(/foo/g, 'bar');\n        }\n      }\n    }]\n  }\n};\n```\n\nSee [htmlclean](https://github.com/anseki/htmlclean#options) for the options.  \nAlso, the following additional option is available.\n\n### `raw`\n\n*Type:* boolean  \n*Default:* Automatic\n\nThis loader outputs a JavaScript code when it is specified as a final loader, otherwise it outputs a raw HTML code for next loader that expects it to be given, automatically.  \nThat is, when it is specified as a final loader, it works like that a `raw-loader` is chained to the list of loaders.  \nFor example, the following two codes work same:\n\n```js\n// webpack.config.js\nmodule.exports = {\n  // ...\n  module: {\n    // Actually, `raw-loader` is unnecessary.\n    rules: [{test: /\\.html$/, use: ['raw-loader', 'htmlclean-loader']}]\n    // htmlclean-loader passes a raw HTML code to raw-loader,\n    // and raw-loader changes it to a JavaScript code and outputs it.\n  }\n};\n```\n\n```js\n// webpack.config.js\nmodule.exports = {\n  // ...\n  module: {\n    rules: [{test: /\\.html$/, loader: 'htmlclean-loader'}]\n    // htmlclean-loader outputs a JavaScript code.\n  }\n};\n```\n\nBy default, it chooses the JavaScript code or the raw HTML code automatically.  \nIf `true` is specified for `raw` option, it chooses a raw HTML code always. If `false` is specified for `raw` option, it chooses a JavaScript code always.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanseki%2Fhtmlclean-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanseki%2Fhtmlclean-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanseki%2Fhtmlclean-loader/lists"}