{"id":18764489,"url":"https://github.com/modernweb-dev/rollup-plugin-import-meta-assets","last_synced_at":"2025-12-07T07:30:19.877Z","repository":{"id":216700863,"uuid":"742076917","full_name":"modernweb-dev/rollup-plugin-import-meta-assets","owner":"modernweb-dev","description":"Rollup plugin that detects assets references relative to modules using patterns such as `new URL('./path/to/asset.ext', import.meta.url)`. The assets are added to the rollup pipeline, allowing them to be transformed and hash the filenames.","archived":false,"fork":false,"pushed_at":"2024-04-11T04:40:55.000Z","size":222,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-04-14T00:24:14.975Z","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/modernweb-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"github":"modernweb-dev","open_collective":"modern-web"}},"created_at":"2024-01-11T18:02:54.000Z","updated_at":"2024-04-16T07:24:21.274Z","dependencies_parsed_at":"2024-01-14T12:16:54.003Z","dependency_job_id":"cb0ba434-9bc0-4b12-a984-90bba4e6d61e","html_url":"https://github.com/modernweb-dev/rollup-plugin-import-meta-assets","commit_stats":{"total_commits":6,"total_committers":2,"mean_commits":3.0,"dds":"0.16666666666666663","last_synced_commit":"cbf2a03ce1c1d6762004fd458201375071f50d94"},"previous_names":["modernweb-dev/rollup-plugin-import-meta-assets"],"tags_count":0,"template":false,"template_full_name":"modernweb-dev/package-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernweb-dev%2Frollup-plugin-import-meta-assets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernweb-dev%2Frollup-plugin-import-meta-assets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernweb-dev%2Frollup-plugin-import-meta-assets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/modernweb-dev%2Frollup-plugin-import-meta-assets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/modernweb-dev","download_url":"https://codeload.github.com/modernweb-dev/rollup-plugin-import-meta-assets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239294483,"owners_count":19615147,"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-11-07T18:30:02.399Z","updated_at":"2025-12-07T07:30:19.821Z","avatar_url":"https://github.com/modernweb-dev.png","language":"JavaScript","funding_links":["https://github.com/sponsors/modernweb-dev","https://opencollective.com/modern-web"],"categories":[],"sub_categories":[],"readme":"# Rollup Plugin import-meta-assets\n\nRollup plugin that detects assets references relative to modules using patterns such as `new URL('./assets/my-img.png', import.meta.url)`.\n\nThe referenced assets are added to the rollup pipeline, allowing them to be transformed and hash the filenames.\n\n## How it works\n\nA common pattern is to import an asset to get the URL of it after bundling:\n\n```js\nimport myImg from './assets/my-img.png';\n```\n\nThis doesn't work in the browser without transformation. This plugin makes it possible to use an identical pattern using `import.meta.url` which does work in the browser:\n\n```js\nconst myImg = new URL('./assets/my-img.png', import.meta.url);\n```\n\n### Dynamic variables\n\nYou can also use dynamic variables like so:\n\n```js\nconst myImg = new URL(`./assets/${myImg}.png`, import.meta.url);\n```\n\nPlease consult the [dynamic-import-vars plugin](https://github.com/rollup/plugins/blob/master/packages/dynamic-import-vars) documentation for options and limitations.\n\n## Install\n\nUsing npm:\n\n```\nnpm install @web/rollup-plugin-import-meta-assets --save-dev\n```\n\n## Usage\n\nCreate a rollup.config.js [configuration file](https://www.rollupjs.org/guide/en/#configuration-files) and import the plugin:\n\n```js\nimport { importMetaAssets } from '@web/rollup-plugin-import-meta-assets';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'output',\n    format: 'es',\n  },\n  plugins: [importMetaAssets()],\n};\n```\n\nThen call `rollup` either via the [CLI](https://www.rollupjs.org/guide/en/#command-line-reference) or the [API](https://www.rollupjs.org/guide/en/#javascript-api).\n\n## Documentation\n\nSee [our website](https://modern-web.dev/docs/building/rollup-plugin-import-meta-assets/) for full documentation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodernweb-dev%2Frollup-plugin-import-meta-assets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmodernweb-dev%2Frollup-plugin-import-meta-assets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmodernweb-dev%2Frollup-plugin-import-meta-assets/lists"}