{"id":24629454,"url":"https://github.com/demsking/gulp-web-dependencies","last_synced_at":"2025-05-07T22:13:30.871Z","repository":{"id":57259502,"uuid":"71692604","full_name":"demsking/gulp-web-dependencies","owner":"demsking","description":"Parse your HTML/JS files and copy bower/npm dependencies to your destination directory","archived":false,"fork":false,"pushed_at":"2021-09-21T10:04:55.000Z","size":43,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T17:25:59.594Z","etag":null,"topics":["bower","dependencies","gulp","gulpplugin","html","javascript","js","npm","vendor"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/gulp-web-dependencies","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/demsking.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-10-23T09:11:52.000Z","updated_at":"2023-08-29T04:54:36.000Z","dependencies_parsed_at":"2022-08-25T03:22:35.331Z","dependency_job_id":null,"html_url":"https://github.com/demsking/gulp-web-dependencies","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demsking%2Fgulp-web-dependencies","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demsking%2Fgulp-web-dependencies/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demsking%2Fgulp-web-dependencies/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/demsking%2Fgulp-web-dependencies/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/demsking","download_url":"https://codeload.github.com/demsking/gulp-web-dependencies/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252883598,"owners_count":21819206,"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":["bower","dependencies","gulp","gulpplugin","html","javascript","js","npm","vendor"],"created_at":"2025-01-25T06:12:55.534Z","updated_at":"2025-05-07T22:13:30.849Z","avatar_url":"https://github.com/demsking.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gulp-web-dependencies\nParse your HTML/JS file and copy bower/npm dependencies to your destination directory\n\n[![Build Status](https://travis-ci.org/demsking/gulp-web-dependencies.svg?branch=master)](https://travis-ci.org/demsking/gulp-web-dependencies)\n[![bitHound Overall Score](https://www.bithound.io/github/demsking/gulp-web-dependencies/badges/score.svg)](https://www.bithound.io/github/demsking/gulp-web-dependencies)\n[![bitHound Dependencies](https://www.bithound.io/github/demsking/gulp-web-dependencies/badges/dependencies.svg)](https://www.bithound.io/github/demsking/gulp-web-dependencies/master/dependencies/npm)\n[![bitHound Dev Dependencies](https://www.bithound.io/github/demsking/gulp-web-dependencies/badges/devDependencies.svg)](https://www.bithound.io/github/demsking/gulp-web-dependencies/master/dependencies/npm)\n[![bitHound Code](https://www.bithound.io/github/demsking/gulp-web-dependencies/badges/code.svg)](https://www.bithound.io/github/demsking/gulp-web-dependencies)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n\n## Install\n\n`npm install --save-dev gulp-web-dependencies`\n\n## Usage\nThe project structure:\n```\nproject/\n├── bower_components\n│   ├── bootstrap\n│   │   └── dist\n│   │       ├── css\n│   │       │   ├── bootstrap.min.css\n│   │       │   ├── bootstrap-theme.min.css\n│   │       │   └── ...\n│   │       └── js\n│   │           ├── bootstrap.min.js\n│   │           └── ...\n│   ├── require1k\n│   │   └── require1k.min.js\n│   └── jquery\n│       └── dist\n│           ├── jquery.min.js\n│           └── ...\n├── node_modules\n│   ├── angular\n│   │   └── angular.min.js\n│   └── firebase\n│       ├── app.js\n│       ├── auth.js\n│       └── ...\n├── src\n│   ├── index.html\n│   └── app.js\n└── gulpfile.js\n```\n\nUse relative paths for NPM/Bower dependencies:\n\nThe `index.html`:\n\n```html\n\u003c!doctype html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eTest file\u003c/title\u003e\n        \u003cmeta charset=\"utf-8\"\u003e\n        \u003clink rel=\"stylesheet\" href=\"../bower_components/bootstrap/dist/css/bootstrap.min.css\"\u003e\n        \u003clink rel=\"stylesheet\" href=\"../bower_components/bootstrap/dist/css/bootstrap-theme.min.css\"\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003ch1\u003ePage title\u003c/h1\u003e\n        \u003cp\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur tempus enim leo, ac lacinia purus accumsan sit amet. In ultrices sagittis nulla, ut dapibus.\u003c/p\u003e\n        \n        \u003cscript src=\"../bower_components/bootstrap/dist/js/bootstrap.min.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"../bower_components/jquery/dist/jquery.min.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"../node_modules/angular/angular.min.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"../bower_components/require1k/require1k.min.js\" data-main=\"./app\"\u003e\u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nThe `app.js`:\n\n```js\nvar _app = require('../node_modules/firebase/app');\nvar _auth = require('../node_modules/firebase/auth');\n\n// ...\n```\n\nIn your `gulpfile.js`, add the task:\n\n```js\nvar gulp = require('gulp')\n  , dependencies = require('gulp-web-dependencies');\n\nvar path_dest = 'dist';\n\ngulp.task('dependencies', function() {\n    return gulp.src('src/index.html')\n        .pipe(dependencies({\n            dest: path_dest,    // The basedir of your application. default: path.dirname(file.path)\n            prefix: '/vendor',  // The URL prefix. Default \"/\"\n        }))\n        .pipe(gulp.dest(path_dest));\n});\n\n// or using a template preprocessing (pug)\ngulp.task('dependencies-jade', function() {\n    return gulp.src('src/app.js')\n        .pipe(pug())\n        .pipe(dependencies({\n            dest: path_dest, \n            prefix: '/vendor',\n        }))\n        .pipe(gulp.dest(path_dest));\n});\n\n// parsing js files\ngulp.task('dependencies-js', function() {\n    return gulp.src('src/app.js', { base: 'src' })\n        .pipe(dependencies({\n            dest: path_dest,\n            base: 'src' // the gulp.src base value\n        }))\n        .pipe(gulp.dest(path_dest));\n});\n\n// Gulp Default Task\ngulp.task('default', ['dependencies', 'dependencies-jade', 'dependencies-js']);\n\n```\n\nAfter the build, get:\n\n```\nproject/\n├── bower_components\n│   └── ...\n├── dist\n│   ├── index.html\n│   ├── products.html\n│   ├── node_modules\n│   │   └── firebase\n│   │       ├── app.js\n│   │       └── auth.js\n│   └── vendor\n│       ├── angular\n│       │   └── angular.min.js\n│       ├── bootstrap\n│       │   └── dist\n│       │       ├── css\n│       │       │   ├── bootstrap.min.css\n│       │       │   └── bootstrap-theme.min.css\n│       │       └── js\n│       │           └── bootstrap.min.js\n│       └── jquery\n│           └── dist\n│               └── jquery.min.js\n├── node_modules\n│   └── ...\n├── src\n│   ├── index.html\n│   └── app.js\n└── gulpfile.js\n```\n\n`index.html`:\n\n```html\n\u003c!doctype html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eTest file\u003c/title\u003e\n        \u003cmeta charset=\"utf-8\"\u003e\n        \u003clink rel=\"stylesheet\" href=\"/vendor/bootstrap/dist/css/bootstrap.min.css\"\u003e\n        \u003clink rel=\"stylesheet\" href=\"/vendor/bootstrap/dist/css/bootstrap-theme.min.css\"\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003ch1\u003ePage title\u003c/h1\u003e\n        \u003cp\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit.\u003c/p\u003e\n        \n        \u003cscript src=\"/vendor/bootstrap/dist/js/bootstrap.min.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/vendor/jquery/dist/jquery.min.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/vendor/angular/angular.min.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"plugins.js\"\u003e\u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n\n```\n\n`app.js`:\n\n```js\nvar _app = require('firebase/app');\nvar _auth = require('firebase/auth');\n\n// ...\n```\n\n## Use the your own search folders pattern\n\nYou can use the the `folders` option to define your search folders pattern. Each folder is separated by a pipe `|`:\n\n```js\ngulp.task('dependencies', function() {\n    return gulp.src('src/**/*.pug')\n        .pipe(pug())\n        .pipe(dependencies({\n            folders: 'bower|assets',\n            dest: 'dist',\n            prefix: '/vendor',\n        }))\n        .pipe(gulp.dest('dist'));\n});\n\n```\n\n## Use the flat option\n\n\n```js\ngulp.task('dependencies', function() {\n    return gulp.src('src/**/*.pug')\n        .pipe(pug())\n        .pipe(dependencies({\n            dest: 'dist',\n            prefix: '/vendor',\n            flat: true\n        }))\n        .pipe(gulp.dest('dist'));\n});\n\n\n```\n\nAfter the build, get:\n\n```\nproject/\n├── ...\n├── dist\n│   ├── ..\n│   └── vendor\n│       ├── angular.min.js\n│       ├── bootstrap.min.css\n│       ├── bootstrap.min.js\n│       ├── bootstrap-theme.min.css\n│       └── jquery.min.js\n├── ...\n```\n\n```html\n\u003c!doctype html\u003e\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eTest file\u003c/title\u003e\n        \u003cmeta charset=\"utf-8\"\u003e\n        \u003clink rel=\"stylesheet\" href=\"/vendor/bootstrap.min.css\"\u003e\n        \u003clink rel=\"stylesheet\" href=\"/vendor/bootstrap-theme.min.css\"\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003ch1\u003ePage title\u003c/h1\u003e\n        \u003cp\u003eLorem ipsum dolor sit amet, consectetur adipiscing elit.\u003c/p\u003e\n        \n        \u003cscript src=\"/vendor/bootstrap.min.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/vendor/jquery.min.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"/vendor/angular/angular.min.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"plugins.js\"\u003e\u003c/script\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n\n```\n\n## License\n\nUnder the MIT license. See [LICENSE](https://github.com/demsking/gulp-web-dependencies/blob/master/LICENSE) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemsking%2Fgulp-web-dependencies","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdemsking%2Fgulp-web-dependencies","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdemsking%2Fgulp-web-dependencies/lists"}