{"id":15357199,"url":"https://github.com/gera2ld/gulp-assets-injector","last_synced_at":"2026-06-07T19:32:55.461Z","repository":{"id":57256805,"uuid":"72331082","full_name":"gera2ld/gulp-assets-injector","owner":"gera2ld","description":"A gulp plugin to collect and inject assets into HTMLs.","archived":false,"fork":false,"pushed_at":"2017-07-13T15:46:04.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T06:49:33.248Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/gera2ld.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":"2016-10-30T06:05:28.000Z","updated_at":"2016-10-30T06:32:51.000Z","dependencies_parsed_at":"2022-08-25T02:30:27.794Z","dependency_job_id":null,"html_url":"https://github.com/gera2ld/gulp-assets-injector","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fgulp-assets-injector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fgulp-assets-injector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fgulp-assets-injector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gera2ld%2Fgulp-assets-injector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gera2ld","download_url":"https://codeload.github.com/gera2ld/gulp-assets-injector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241913788,"owners_count":20041459,"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":"2024-10-01T12:33:56.470Z","updated_at":"2026-06-07T19:32:55.452Z","avatar_url":"https://github.com/gera2ld.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"gulp-assets-injector\n===\n\n![NPM](https://img.shields.io/npm/v/gulp-assets-injector.svg)\n![License](https://img.shields.io/npm/l/gulp-assets-injector.svg)\n![Downloads](https://img.shields.io/npm/dt/gulp-assets-injector.svg)\n\nA plugin to inject assets into HTMLs.\n\nUsage\n---\nFirst collect static files via `assetsInjector.collect()`, then inject them\nvia `assetsInjector.inject()`.\n\n``` js\nconst gulp = require('gulp');\nconst assetsInjector = require('gulp-assets-injector')();\n\ngulp.task('js', () =\u003e {\n  return gulp.src('src/**/*.js')\n  .pipe(assetsInjector.collect())\n  .pipe(gulp.dest('dist'));\n});\n\ngulp.task('css', () =\u003e {\n  return gulp.src('src/**/*.css')\n  .pipe(assetsInjector.collect())\n  .pipe(gulp.dest('dist'));\n});\n\ngulp.task('html', ['js', 'css'], () =\u003e {\n  return gulp.src('src/index.html')\n  .pipe(assetsInjector.inject())\n  .pipe(gulp.dest('dist'));\n});\n\n// and a more complexed example\nconst injectOptions = {\n  link: true,\n  filter: (htmlPath, assetPath) =\u003e assetPath.includes('/home/'),\n}\ngulp.task('html-complex', ['js', 'css'], () =\u003e {\n  return gulp.src('src/home.html')\n  .pipe(assetsInjector.inject(injectOptions))\n  .pipe(gulp.dest('dist'));\n});\n```\n\nIf `injectOptions.link` is set to false, HTMLs will be injected with asset contents directly:\n``` html\n\u003cstyle\u003e/* css here */\u003c/style\u003e\n...\n\u003cscript\u003e//\u003c![CDATA[\n/* script here */\n//]]\u003e\u003c/script\u003e\n```\n\nOtherwise HTMLs will be injected with links:\n``` html\n\u003clink rel=\"stylesheet\" href=\"style.css\"\u003e\n...\n\u003cscript src=\"app.js\"\u003e\u003c/script\u003e\n```\n\nIf `injectOptions.link` is a function, the returned value will be used as asset paths.\n\nDocument\n---\n\n* AssetsInjector\n\n  The constructor takes no arguments.\n\n* AssetsInjector::collect()\n\n  Collects all the static files piped to it.\n\n* AssetsInjector::inject(*Optional* options)\n\n  Inject the collected static files to the piped HTMLs.\n\n  `options` is an object with following properties:\n\n  * link: *Any*\n\n    Whether the assets should be injected as a link. If set to false, the content will be injected into HTML directly. Default as `true`.\n\n    If set to a function, the injected link URL will be determined by the function, the parameters are `path/to/HTML` and `path/to/asset`.\n\n  * filter: *Function*\n\n    A function to decide whether an asset file should be injected into the current HTML. The parameters are `path/to/HTML` and `path/to/asset`.\n\n    If not provided, all assets within the same directory as the current HTML will be injected.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgera2ld%2Fgulp-assets-injector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgera2ld%2Fgulp-assets-injector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgera2ld%2Fgulp-assets-injector/lists"}