{"id":24083323,"url":"https://github.com/mitranim/gulp-html-to-js","last_synced_at":"2025-04-30T18:23:16.674Z","repository":{"id":34337955,"uuid":"38258351","full_name":"mitranim/gulp-html-to-js","owner":"mitranim","description":"Gulp plugin for converting text files to JavaScript modules","archived":false,"fork":false,"pushed_at":"2018-08-24T13:53:38.000Z","size":16,"stargazers_count":4,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-26T06:56:56.636Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitranim.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-06-29T16:35:24.000Z","updated_at":"2019-08-15T17:56:07.000Z","dependencies_parsed_at":"2022-08-25T21:23:34.900Z","dependency_job_id":null,"html_url":"https://github.com/mitranim/gulp-html-to-js","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitranim%2Fgulp-html-to-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitranim%2Fgulp-html-to-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitranim%2Fgulp-html-to-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitranim%2Fgulp-html-to-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitranim","download_url":"https://codeload.github.com/mitranim/gulp-html-to-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251758724,"owners_count":21639096,"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":[],"created_at":"2025-01-09T23:56:23.029Z","updated_at":"2025-04-30T18:23:16.647Z","avatar_url":"https://github.com/mitranim.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Overview\n\nA [`gulp`](http://gulpjs.com) plugin that converts arbitrary text files into JavaScript modules. Not limited to HTML.\n\n## Installation\n\n```sh\nnpm i -E gulp-html-to-js\n# or\nyarn add -E gulp-html-to-js\n```\n\n## Usage\n\nIn your `gulpfile.js`:\n\n```js\nconst htmlToJs = require('gulp-html-to-js')\n\n// Without concatenation\ngulp.task('html:compile', () =\u003e (\n  gulp.src('src/html/**/*')\n    .pipe(htmlToJs())\n    .pipe(gulp.dest('dist'))\n))\n\n// With concatenation\ngulp.task('html:compile', () =\u003e (\n  gulp.src('src/html/**/*')\n    .pipe(htmlToJs({concat: 'html.js'}))\n    .pipe(gulp.dest('dist'))\n))\n```\n\nWithout the `concat` option, each module exports a single string:\n\n```html\n\u003cp\u003eHello world!\u003c/p\u003e\n```\n\nBecomes:\n\n```js\nmodule.exports = '\u003cp\u003eHello world!\u003c/p\u003e'\n```\n\nWith `concat`, files are grouped into one module, where strings are keyed by file paths:\n\n```js\nmodule.exports = Object.create(null)\nmodule.exports['index.html'] = '\u003cp\u003eHello world!\u003c/p\u003e'\n```\n\nIn your app, import the result like so (directory nesting depends on your build configuration):\n\n```js\nimport html from './html.js'\n// or\nconst html = require('./html.js')\n```\n\n## Options\n\nSee the `concat` option above. You can also modify it with:\n\n* `prefix`: Prepends a path prefix to all keys of the resulting module object.\n\nFor `{prefix: 'templates'}` the resulting file from the above example is:\n\n```js\nmodule.exports = Object.create(null)\nmodule.exports['templates/index.html'] = '\u003cp\u003eHello world!\u003c/p\u003e'\n```\n\n* `global`: Requires `concat`. Assigns the resulting object to some global identifier other than `module.exports` (default).\n\nFor `{global: 'window.templates', concat: 'templates.js'}` the example above would produce this:\n\n```js\nwindow.templates = Object.create(null)\nwindow.templates['index.html'] = '\u003cp\u003eHello world!\u003c/p\u003e'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitranim%2Fgulp-html-to-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitranim%2Fgulp-html-to-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitranim%2Fgulp-html-to-js/lists"}