{"id":14976361,"url":"https://github.com/caiogondim/webpack-conditional-loader","last_synced_at":"2025-04-09T14:13:28.546Z","repository":{"id":65419356,"uuid":"98583149","full_name":"caiogondim/webpack-conditional-loader","owner":"caiogondim","description":"C conditionals directive for JavaScript","archived":false,"fork":false,"pushed_at":"2020-01-07T08:05:47.000Z","size":137,"stargazers_count":110,"open_issues_count":17,"forks_count":24,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T12:05:23.441Z","etag":null,"topics":["javascript","optimization","webpack","webpack-loader","webpack2"],"latest_commit_sha":null,"homepage":"https://npm.im/webpack-conditional-loader","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/caiogondim.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":"2017-07-27T22:00:40.000Z","updated_at":"2024-12-08T09:29:50.000Z","dependencies_parsed_at":"2023-01-22T18:15:30.878Z","dependency_job_id":null,"html_url":"https://github.com/caiogondim/webpack-conditional-loader","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiogondim%2Fwebpack-conditional-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiogondim%2Fwebpack-conditional-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiogondim%2Fwebpack-conditional-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/caiogondim%2Fwebpack-conditional-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/caiogondim","download_url":"https://codeload.github.com/caiogondim/webpack-conditional-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248054193,"owners_count":21039952,"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","optimization","webpack","webpack-loader","webpack2"],"created_at":"2024-09-24T13:53:46.744Z","updated_at":"2025-04-09T14:13:28.504Z","avatar_url":"https://github.com/caiogondim.png","language":"JavaScript","readme":"\u003cimg src=\"http://rawgit.com/caiogondim/webpack-conditional-loader/master/logo/banner.svg\" width=\"100%\" /\u003e\n\n# webpack-conditional-loader\n\n\u003cdiv\u003e\n  \u003ca href=\"https://www.npmjs.com/package/webpack-conditional-loader\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/webpack-conditional-loader.svg\" /\u003e\u003c/a\u003e\n\u003c/div\u003e\n\n\u003cbr\u003e\n\nInspired by [C conditionals directive](https://gcc.gnu.org/onlinedocs/gcc-3.0.2/cpp_4.html),\nconditional loader decides if a given block should be included in the final bundle.\n\nUseful for removing instrumentation code and making your final production bundle smaller (therefore\nfaster).\n\n## Installation\n\n```bash\nnpm install --save-dev webpack-conditional-loader\n```\n\n## Usage\n\n### In your `webpack.config.js`\n\nPut `webpack-conditional-loader` as the last loader in the array, so it will process the code before\nall others.\n\n```js\nmodule: {\n  rules: [{\n    test: /\\.js$/,\n    use: ['babel-loader', 'webpack-conditional-loader']\n  }]\n}\n```\n\nGet an example config file [here](https://github.com/caiogondim/webpack-conditional-loader/blob/master/webpack.js)\n\n### On your code\n\nUse `// #if expression` and `// #endif` to wrap blocks of code you want to be removed if a given\npredicate is false.\n\n```js\n// #if process.env.NODE_ENV === 'DEVELOPMENT'\nconsole.log('lorem')\nconsole.log('ipsum')\n// #endif\n```\n\nIn the example above, the code will be removed if the enviroment variable `NODE_ENV` is not\n`DEVELOPMENT`, removing unnecessary code from your production bundle.\n\nThe same technique can be used to prevent loading packages in the production bundle.\n\n```js\n// #if process.env.NODE_ENV !== 'BUILD'\nimport reduxLogger from 'redux-logger'\n// #endif\n```\n\n## Credits\n- [GCC C conditional documentation](https://gcc.gnu.org/onlinedocs/gcc-3.0.2/cpp_4.html)\n\n---\n\n[caiogondim.com](https://caiogondim.com) \u0026nbsp;\u0026middot;\u0026nbsp;\nGitHub [@caiogondim](https://github.com/caiogondim) \u0026nbsp;\u0026middot;\u0026nbsp;\nTwitter [@caio_gondim](https://twitter.com/caio_gondim)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiogondim%2Fwebpack-conditional-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcaiogondim%2Fwebpack-conditional-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcaiogondim%2Fwebpack-conditional-loader/lists"}