{"id":17590972,"url":"https://github.com/stafyniaksacha/metalsmith-js-packer","last_synced_at":"2025-04-29T10:37:32.534Z","repository":{"id":57295577,"uuid":"98525239","full_name":"stafyniaksacha/metalsmith-js-packer","owner":"stafyniaksacha","description":"Javascript packer/minifier/uglifier for metalsmith","archived":false,"fork":false,"pushed_at":"2023-04-18T19:16:22.000Z","size":66,"stargazers_count":5,"open_issues_count":8,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T15:44:17.587Z","etag":null,"topics":["javascript","metalsmith","minifier","packer","uglify"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stafyniaksacha.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-27T10:49:35.000Z","updated_at":"2023-02-10T22:54:16.000Z","dependencies_parsed_at":"2024-10-23T01:04:29.868Z","dependency_job_id":null,"html_url":"https://github.com/stafyniaksacha/metalsmith-js-packer","commit_stats":{"total_commits":4,"total_committers":3,"mean_commits":"1.3333333333333333","dds":0.5,"last_synced_commit":"df1562774b73996f21a7e91a842ccd65b163ab63"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stafyniaksacha%2Fmetalsmith-js-packer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stafyniaksacha%2Fmetalsmith-js-packer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stafyniaksacha%2Fmetalsmith-js-packer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stafyniaksacha%2Fmetalsmith-js-packer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stafyniaksacha","download_url":"https://codeload.github.com/stafyniaksacha/metalsmith-js-packer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251484806,"owners_count":21596816,"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":["javascript","metalsmith","minifier","packer","uglify"],"created_at":"2024-10-22T04:43:49.348Z","updated_at":"2025-04-29T10:37:32.497Z","avatar_url":"https://github.com/stafyniaksacha.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# metalsmith-js-packer\n\u003e Javascript packer/minifier/uglifier for metalsmith\"\n\nThis plugin is a Javascript optimizer: it will pass on generated HTML, look for scripts tags (external, internal, inline) and bundle all script in one place.\n\nYou can chose to pack your script in one file, as this, packed script can be reused through multiple pages. Or you can directly insert packed script as inline script.\n\n*If this plugin doesn't fit your needs, please don't hesitate to ask for feature requests.*\n\n## Installation\n```bash\nnpm install --save metalsmith-js-packer\n```\n\n## Usage\n\n### Javascript API\n\nThe example bellow show the minimum code needed to pack your files.\n\n```javascript\nconst metalsmith = require('metalsmith');\nconst jsPacker = require('metalsmith-js-packer');\n\nmetalsmith(__dirname)\n  .source('./src')\n  .use(jsPacker())\n  .build();\n```\n\n### Examples\n\nHere is an example with generated HTML output file\n\n#### HTML Input\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eMy awesome page !\u003c/title\u003e\n\n    \u003cscript src=\"//cdn.example.com/jquery.min.js\"\u003e\n    \u003cscript src=\"//cdn.example.com/jquery-plugin.min.js\"\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n\n    \u003c!-- Imagine we have an awesome website here --\u003e\n\n    \u003cscript\u003e\n      var globalVariable = 'registered here';\n\n      (function() {\n        var contextedVariable = 'registered here';\n      })();\n    \u003c/script\u003e\n\n    \u003cscript src=\"/assets/javascript/application.js\"\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n#### HTML Output\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eMy awesome page !\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n\n    \u003c!-- Imagine we have an awesome website here --\u003e\n\n    \u003cscript src=\"/assets/javascript/e6791aa54bf763f10700a88b38d578282663be53.min.js\"\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\u003e Here we can see, all script tags are packed/uglified in one file,  \nwhich is included and writed on filesystem\n\n### Exclude script element from packing\n\n\n#### HTML Input\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eMy awesome page !\u003c/title\u003e\n\n    \u003cscript src=\"//cdn.example.com/jquery.min.js\"\u003e\n    \u003cscript src=\"//cdn.example.com/jquery-plugin.min.js\"\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n\n    \u003c!-- Imagine we have an awesome website here --\u003e\n\n    \u003cscript data-packer=\"exclude\"\u003e\n      var globalVariable = 'registered here';\n\n      (function() {\n        var contextedVariable = 'registered here';\n      })();\n    \u003c/script\u003e\n\n    \u003cscript src=\"/assets/javascript/application.js\"\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n#### HTML Output\n\n```html\n\u003chtml\u003e\n  \u003chead\u003e\n    \u003ctitle\u003eMy awesome page !\u003c/title\u003e\n  \u003c/head\u003e\n  \u003cbody\u003e\n\n    \u003c!-- Imagine we have an awesome website here --\u003e\n\n    \u003cscript\u003e\n      var globalVariable = 'registered here';\n\n      (function() {\n        var contextedVariable = 'registered here';\n      })();\n    \u003c/script\u003e\n\n    \u003c!-- notice that hash has changed, and another file is created --\u003e\n    \u003cscript src=\"/assets/javascript/0cex1a4bquf764r4ge1relmb3v2ba3s8o6k3wetj.min.js\" /\u003e\n  \u003c/body\u003e\n\u003c/html\u003e\n```\n\n## Options reference\n| name   |  default  |  description  |\n| --- | --- | --- |\n| `inline` | `false` | if `true`, write packed content in a inline script tag instead of a local script |\n| `siteRootPath` | `/` | Use if your site root path is not `/` |\n| `ouputPath` | `assets/javascript/` | Customize output location of packed script |\n| `uglify` | `true` | Enable/disable script uglify |\n| `uglifyOptions` | `{}` | Options passed to [uglify](https://www.npmjs.com/package/uglify-js) |\n\n\u003e hint: metalsmith-js-packer use debug\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstafyniaksacha%2Fmetalsmith-js-packer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstafyniaksacha%2Fmetalsmith-js-packer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstafyniaksacha%2Fmetalsmith-js-packer/lists"}