{"id":20631893,"url":"https://github.com/andrelmlins/variables-loader","last_synced_at":"2025-04-15T18:56:56.658Z","repository":{"id":57390848,"uuid":"240595953","full_name":"andrelmlins/variables-loader","owner":"andrelmlins","description":"Webpack loader to parse variables","archived":false,"fork":false,"pushed_at":"2023-03-04T06:02:47.000Z","size":130,"stargazers_count":8,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-22T19:05:51.629Z","etag":null,"topics":["loader","parse-variables","variables-loader","webpack","webpack-loader"],"latest_commit_sha":null,"homepage":null,"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/andrelmlins.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":"2020-02-14T20:47:48.000Z","updated_at":"2023-03-09T02:26:13.000Z","dependencies_parsed_at":"2024-11-16T18:15:05.837Z","dependency_job_id":null,"html_url":"https://github.com/andrelmlins/variables-loader","commit_stats":{"total_commits":40,"total_committers":3,"mean_commits":"13.333333333333334","dds":"0.050000000000000044","last_synced_commit":"1ce5e3b7f1b861fb1616f2bf8ce8f57ee3a58901"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrelmlins%2Fvariables-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrelmlins%2Fvariables-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrelmlins%2Fvariables-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrelmlins%2Fvariables-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrelmlins","download_url":"https://codeload.github.com/andrelmlins/variables-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249135789,"owners_count":21218365,"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":["loader","parse-variables","variables-loader","webpack","webpack-loader"],"created_at":"2024-11-16T14:14:04.896Z","updated_at":"2025-04-15T18:56:56.638Z","avatar_url":"https://github.com/andrelmlins.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Variables loader\n\nWebpack loader to parse variables\n\n[![npm version](https://badge.fury.io/js/variables-loader.svg)](https://www.npmjs.com/package/variables-loader) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/andrelmlins/variables-loader/blob/master/LICENSE) [![Build Status](https://travis-ci.com/andrelmlins/variables-loader.svg?branch=master)](https://travis-ci.com/andrelmlins/variables-loader)\n\n## Install\n\n```\nnpm install variables-loader\n```\n\nor\n\n```\nyarn add variables-loader\n```\n\n## Usage\n\n**env.js**\n\n```js\nmodule.exports = () =\u003e {\n  return {\n    URL: \"http://www.example.com\"\n  };\n};\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(ts|js)x?$/,\n        use: [\"variables-loader\"]\n      }\n    ]\n  }\n};\n```\n\n### How will the result be?\n\n**before in Link.jsx**\n\n```jsx\nimport React from \"react\";\n\nconst LinkComponent = () =\u003e \u003ca href=\"[[URL]]\"\u003eLink\u003c/a\u003e;\n\nexport default LinkComponent;\n```\n\n**after in Link.jsx**\n\n```jsx\nimport React from \"react\";\n\nconst LinkComponent = () =\u003e \u003ca href=\"http://www.example.com\"\u003eLink\u003c/a\u003e;\n\nexport default LinkComponent;\n```\n\n## Options\n\n### `fileName`\n\nType `String|Function` Default: `env.js`\n\n**webpack.config.js**\n\n#### `String`\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(ts|js)x?$/,\n        loader: \"variables-loader\",\n        options: {\n          fileName: \"environments.js\"\n        }\n      }\n    ]\n  }\n};\n```\n\n#### `Function`\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(ts|js)x?$/,\n        loader: \"variables-loader\",\n        options: {\n          fileName: () =\u003e {\n            if (process.env.NODE_ENV === \"development\") {\n              return \"environments.test.js\";\n            }\n\n            return \"environments.js\";\n          }\n        }\n      }\n    ]\n  }\n};\n```\n\n### `format`\n\nType `String\u003cjs,json,txt\u003e|Function\u003cjs,json,env\u003e` Default: `js`\n\n**webpack.config.js**\n\n#### `String`\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(ts|js)x?$/,\n        loader: \"variables-loader\",\n        options: {\n          format: \"js\"\n        }\n      }\n    ]\n  }\n};\n```\n\n#### `Function`\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(ts|js)x?$/,\n        loader: \"variables-loader\",\n        options: {\n          format: () =\u003e {\n            if (process.env.NODE_ENV === \"development\") {\n              return \"json\";\n            }\n\n            return \"js\";\n          }\n        }\n      }\n    ]\n  }\n};\n```\n\n### `marker`\n\nType `String|Function|Array` Default: `[[]]`\n\n**webpack.config.js**\n\n#### `String`\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(ts|js)x?$/,\n        loader: \"variables-loader\",\n        options: {\n          marker: \"{{}}\"\n        }\n      }\n    ]\n  }\n};\n```\n\n#### `Function`\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(ts|js)x?$/,\n        loader: \"variables-loader\",\n        options: {\n          marker: () =\u003e {\n            if (process.env.NODE_ENV === \"development\") {\n              return \"{{}}\";\n            }\n\n            return \"[[]]\";\n          }\n        }\n      }\n    ]\n  }\n};\n```\n\n## NPM Statistics\n\nDownload stats for this NPM package\n\n[![NPM](https://nodei.co/npm/variables-loader.png)](https://nodei.co/npm/variables-loader/)\n\n## License\n\nVariables Loader is open source software [licensed as MIT](https://github.com/andrelmlins/variables-loader/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrelmlins%2Fvariables-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrelmlins%2Fvariables-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrelmlins%2Fvariables-loader/lists"}