{"id":15314010,"url":"https://github.com/vanruesc/grunt-inline-import","last_synced_at":"2025-10-08T23:32:12.265Z","repository":{"id":57255201,"uuid":"91137520","full_name":"vanruesc/grunt-inline-import","owner":"vanruesc","description":"A Grunt plugin that inlines custom file imports.","archived":true,"fork":false,"pushed_at":"2018-07-01T21:13:27.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-02T05:14:59.004Z","etag":null,"topics":["custom","file","grunt-plugin","import","inline"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vanruesc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-12T23:51:01.000Z","updated_at":"2023-01-27T21:28:10.000Z","dependencies_parsed_at":"2022-09-26T22:00:26.605Z","dependency_job_id":null,"html_url":"https://github.com/vanruesc/grunt-inline-import","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Fgrunt-inline-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Fgrunt-inline-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Fgrunt-inline-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Fgrunt-inline-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vanruesc","download_url":"https://codeload.github.com/vanruesc/grunt-inline-import/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235775518,"owners_count":19043180,"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":["custom","file","grunt-plugin","import","inline"],"created_at":"2024-10-01T08:44:09.767Z","updated_at":"2025-10-08T23:32:11.925Z","avatar_url":"https://github.com/vanruesc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grunt Inline Import\n\n[![Build status](https://travis-ci.org/vanruesc/grunt-inline-import.svg?branch=master)](https://travis-ci.org/vanruesc/grunt-inline-import)\n[![npm version](https://badge.fury.io/js/grunt-inline-import.svg)](https://badge.fury.io/js/grunt-inline-import)\n[![Dependencies](https://david-dm.org/vanruesc/grunt-inline-import.svg?branch=master)](https://david-dm.org/vanruesc/grunt-inline-import)\n\nA Grunt plugin that [inlines file imports](https://github.com/vanruesc/inline-import). \n\n\n## Getting Started\n\nThis plugin requires Grunt \u003e= 0.4.0\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) \nguide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. \nOnce you're familiar with that process, you may install this plugin with this command:\n\n```sh\nnpm install grunt-inline-import --save-dev\n``` \n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks(\"grunt-inline-import\");\n```\n\n\n## Usage\n\nThe inlining process is __destructive__. Affected files will be changed __permanently__. Create a \n[backup](https://github.com/vanruesc/grunt-inline-import#creating-a-backup) first!  \nTo inline your file imports, you need to specify the path to the JavaScript \nfile that should be modified. Additionally, you need to define the \n```extensions``` of the relevant import statements.\n\n#### text.txt\n\n```\nhello world\n```\n\n#### index.js\n\n```javascript\nimport component from \"module\";\nimport text from \"./text.txt\";\n```\n\n#### Gruntfile.js\n\n```javascript\ninlineImport: {\n\toptions: {\n\t\textensions: {\n\t\t\t\".txt\": \"utf8\"\n\t\t}\n\t},\n\ttask: {\n\t\tsrc: \"index.js\"\n\t}\n}\n```\n\n#### index.js (inlined)\n\n```javascript\nimport component from \"module\";\nconst text = \"hello world\";\n```\n\n\n## Glob\n\nYou may use [glob patterns](https://github.com/isaacs/node-glob#glob-primer) to inline several files at once. \n\n```js\ninlineImport: {\n\toptions: {\n\t\textensions: {\n\t\t\t\".html\": \"utf8\",\n\t\t\t\".css\": \"utf8\"\n\t\t}\n\t},\n\ttask: {\n\t\tsrc: \"src/**/tpl.js\"\n\t}\n}\n```\n\n\n## Options\n\nCheck the options of the [inline-import](https://github.com/vanruesc/inline-import#options) tool for details. \n\n```js\ninlineImport: {\n\toptions: {\n\t\t// Global options.\n\t\textensions: {\n\t\t\t\".html\": \"utf8\",\n\t\t\t\".png\": \"base64\"\n\t\t},\n\t\tencoding: \"utf8\",\n\t\tuseVar: true\n\t},\n\ttask: {\n\t\toptions: {\n\t\t\t// Local options.\n\t\t\textensions: {\n\t\t\t\t\".glsl\": \"utf8\"\n\t\t\t}\n\t\t},\n\t\tsrc: \"index.js\"\n\t}\n}\n```\n\n\n## Creating a Backup\n\nIn order to create a backup of specific files, you'll need tools for copying and deleting files. The following example uses the basic grunt \nplugins [grunt-contrib-copy](https://github.com/gruntjs/grunt-contrib-copy) and [grunt-contrib-clean](https://github.com/gruntjs/grunt-contrib-clean).\n\n##### Gruntfile.js (copy setup)\n\n```js\ncopy: {\n\tbackup: {\n\t\texpand: true,\n\t\tcwd: \"src\",\n\t\tsrc: \"**/tpl.js\",  // Copy all tpl files from src into a \n\t\tdest: \"backup\",    // backup folder while maintaining directory structures.\n\t\tfilter: \"isFile\"\n\t},\n\trestore: {\n\t\texpand: true,\n\t\tcwd: \"backup\",\n\t\tsrc: \"**\",         // Copy all backup files back into the \n\t\tdest: \"src\",       // src folder, overwriting existing files.\n\t\tfilter: \"isFile\"\n\t}\n}\n```\n\n##### Gruntfile.js (clean setup)\n\n```js\nclean: {\n\tbackup: [\"backup\"]  // Remove the backup files.\n}\n```\n\n##### Gruntfile.js (tasks)\n\n```js\ngrunt.registerTask(\"backup\", [\"restore\", \"copy:backup\"]);\ngrunt.registerTask(\"restore\", [\"copy:restore\", \"clean:backup\"]);\ngrunt.registerTask(\"prepublish\", [\"backup\", \"inlineImport\"]);\ngrunt.registerTask(\"postpublish\", [\"restore\"]);\n```\n\n\n## Contributing\n\nMaintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanruesc%2Fgrunt-inline-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvanruesc%2Fgrunt-inline-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanruesc%2Fgrunt-inline-import/lists"}