{"id":15313987,"url":"https://github.com/vanruesc/grunt-lemon","last_synced_at":"2025-10-08T23:32:18.573Z","repository":{"id":57255297,"uuid":"55507507","full_name":"vanruesc/grunt-lemon","owner":"vanruesc","description":"A grunt plugin that inlines custom file imports permanently.","archived":true,"fork":false,"pushed_at":"2017-05-20T13:58:03.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-10T01:38:49.813Z","etag":null,"topics":[],"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","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-05T12:51:55.000Z","updated_at":"2023-01-28T20:49:18.000Z","dependencies_parsed_at":"2022-08-31T09:00:22.349Z","dependency_job_id":null,"html_url":"https://github.com/vanruesc/grunt-lemon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Fgrunt-lemon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Fgrunt-lemon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Fgrunt-lemon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vanruesc%2Fgrunt-lemon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vanruesc","download_url":"https://codeload.github.com/vanruesc/grunt-lemon/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":[],"created_at":"2024-10-01T08:43:58.266Z","updated_at":"2025-10-08T23:32:13.301Z","avatar_url":"https://github.com/vanruesc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grunt-lemon (discontinued)\n[![Build status](https://travis-ci.org/vanruesc/grunt-lemon.svg?branch=master)](https://travis-ci.org/vanruesc/grunt-lemon) \n[![npm version](https://badge.fury.io/js/grunt-lemon.svg)](https://badge.fury.io/js/grunt-lemon) \n[![Dependencies](https://david-dm.org/vanruesc/grunt-lemon.svg?branch=master)](https://david-dm.org/vanruesc/grunt-lemon)\n\n__Deprecated in favor of [grunt-inline-import](https://github.com/vanruesc/grunt-inline-import).__\n\nThis grunt plugin inlines file imports in individual files __permanently__. It's best suited for the prepublish phase. \nRestoring the affected files after publishing your module requires you to create a backup of said files. Take a look at the usage \nexample for details. \n\nIf you are using [rollup](https://github.com/rollup/rollup) and [rollup-plugin-string](https://github.com/TrySound/rollup-plugin-string) \nto inline _text_ file imports during the bundling process, you'll be faced with a problem when you decide to publish your module as a library. \nIn order to make full use of rollup's [tree-shaking capabilities](https://github.com/rollup/rollup#a-next-generation-es6-module-bundler), you \ncan't just publish your final bundle. It's important to expose your source files directly, but these files still use custom file imports and \nwill cause errors for the end users of your library!  \n\n\u003e When life gives you lemons, squeeze the lemons and make lemonade.\n\nIn contrast to rollup-plugin-string which focuses on inlining text files, grunt-lemon allows you to inline files of various types. \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-lemon --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-lemon\");\n```\n\n\n## Usage\nThe inlining process is __destructive__. Affected files will be changed __permanently__. Create a \n[backup](https://github.com/vanruesc/grunt-lemon#creating-a-backup) first!  \n\nDefine which imports should be considered by defining the ```options.extensions``` and specify a source path ```src``` to the files \nthat you wish to inline. \n\n```\n// src/my/text.txt\nhello world\n```\n\n```js\n// src/index.js\nimport myModule from \"my-module\";\nimport text from \"./my/text.txt\";\n```\n\n```js\n// Gruntfile.js\nlemon: {\n  options: {\n    extensions: {\n      \".txt\": \"utf8\"\n    }\n  },\n  taskA: {\n    src: \"src/index.js\"\n  },\n  ...\n}\n```\n\n```js\n// src/index.js (inlined)\nimport myModule from \"my-module\";\nconst text = \"hello world\";\n```\n\n\n### Glob\nYou may use [glob patterns](https://github.com/isaacs/node-glob#glob-primer) to inline a bunch of files at once. \n\n```js\nlemon: {\n  options: {\n    extensions: {\n      \".html\": \"utf8\",\n      \".css\": \"utf8\"\n    }\n  },\n  task: {\n    src: \"src/**/tpl.js\"\n  }\n}\n```\n\n\n### Options\n- Only those imports whose file extensions explicitly match one of the specified ```extensions``` will be considered. Each extension defines \nits own encoding. \n- If you don't want to use the _const_ statement, simply set ```useVar``` to _true_.  \n- You can set the  ```encoding``` of the source files that will be parsed. Use one of the possible encoding values specified in node's \n[Buffer](https://github.com/nodejs/node/blob/master/lib/buffer.js) class. The default encoding is _utf8_.  \n- You may also provide ```glob``` options for the underlying [glob](https://github.com/isaacs/node-glob#options) mechanism. \n\n```js\nlemon: {\n  options: {\n    // Global options.\n    extensions: {\n      \".html\": \"utf8\",\n      \".png\": \"base64\"\n    },\n    encoding: \"utf8\",\n    useVar: true,\n    glob: { ... },\n  },\n  squeeze: {\n    options: {\n      // Local options.\n      extensions: {\n        \".glsl\": \"utf8\"\n      }\n    },\n    src: \"src/index.js\"\n  }\n}\n```\n\n\n### Creating a Backup\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```js\n// Gruntfile.js (copy setup)\ncopy: {\n  backup: {\n    expand: true,\n    cwd: \"src\",\n    src: \"**/tpl.js\",  // Copy all tpl files from src into a \n    dest: \"backup\",    // backup folder while maintaining directory structures.\n    filter: \"isFile\"\n  },\n  restore: {\n    expand: true,\n    cwd: \"backup\",\n    src: \"**\",         // Copy all backup files back into the \n    dest: \"src\",       // src folder, overwriting existing files.\n    filter: \"isFile\"\n  }\n}\n```\n\n```js\n// Gruntfile.js (clean setup)\nclean: {\n  backup: [\"backup\"]  // Remove the backup files.\n}\n```\n\n```js\n// Gruntfile.js (tasks)\ngrunt.registerTask(\"backup\", [\"restore\", \"copy:backup\"]);\ngrunt.registerTask(\"restore\", [\"copy:restore\", \"clean:backup\"]);\ngrunt.registerTask(\"prepublish\", [\"backup\", \"lemon\"]);\ngrunt.registerTask(\"postpublish\", [\"restore\"]);\n```\n\n\n## Contributing\nMaintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.\n\n\n## License\n[Zlib](https://github.com/vanruesc/grunt-lemon/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanruesc%2Fgrunt-lemon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvanruesc%2Fgrunt-lemon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvanruesc%2Fgrunt-lemon/lists"}