{"id":15654711,"url":"https://github.com/egoist/webpack-flow","last_synced_at":"2025-05-01T05:14:28.620Z","repository":{"id":45275230,"uuid":"93225911","full_name":"egoist/webpack-flow","owner":"egoist","description":"🎴 Compose webpack config with confidence.","archived":false,"fork":false,"pushed_at":"2021-12-25T14:15:47.000Z","size":44,"stargazers_count":26,"open_issues_count":13,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-01T05:14:20.205Z","etag":null,"topics":["webpack"],"latest_commit_sha":null,"homepage":"","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/egoist.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-06-03T05:32:04.000Z","updated_at":"2020-01-31T07:52:25.000Z","dependencies_parsed_at":"2022-09-06T10:12:52.886Z","dependency_job_id":null,"html_url":"https://github.com/egoist/webpack-flow","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fwebpack-flow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fwebpack-flow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fwebpack-flow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/egoist%2Fwebpack-flow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/egoist","download_url":"https://codeload.github.com/egoist/webpack-flow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251825444,"owners_count":21649955,"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":["webpack"],"created_at":"2024-10-03T12:53:30.674Z","updated_at":"2025-05-01T05:14:28.578Z","avatar_url":"https://github.com/egoist.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webpack-flow\n\n[![NPM version](https://img.shields.io/npm/v/webpack-flow.svg?style=flat)](https://npmjs.com/package/webpack-flow) [![NPM downloads](https://img.shields.io/npm/dm/webpack-flow.svg?style=flat)](https://npmjs.com/package/webpack-flow) [![CircleCI](https://circleci.com/gh/egoist/webpack-flow/tree/master.svg?style=shield\u0026circle-token=e1a1a54deeacf368cc9af44162ef71bc1a255443)](https://circleci.com/gh/egoist/webpack-flow/tree/master) \n [![donate](https://img.shields.io/badge/$-donate-ff69b4.svg?maxAge=2592000\u0026style=flat)](https://github.com/egoist/donate)\n\n## How does this work?\n\n\u003cdetails\u003e\u003csummary\u003eExample\u003c/summary\u003e\u003cbr\u003e\n\n```js\n// Create Webpack Config in a composable way:\nflow.createConfig([\n  flow.entry('./src/index.js'),\n  flow.babel(),\n  flow.env('production', [\n    flow.dest('./dist/[name].[chunkhash].js', {\n      publicPath: '/my/cdn/'\n    })\n  ]),\n  flow.env('development', [\n    flow.dest('dist/[name].js')\n  ])\n])\n```\n\u003c/details\u003e\u003cbr\u003e\n\n`webpack-flow` is similar to [webpack-blocks](https://github.com/andywer/webpack-blocks) but we're using [webpack-chain](https://github.com/mozilla-rpweb/webpack-chain) instead of [webpack-merge](https://github.com/survivejs/webpack-merge) under the hood. With `webpack-chain` you can manage deep nested webpack config in a predictable way while `webpack-merge` kind of looks like a black-box to me.\n\n### flow.createConfig(flows)\n\nIt creates a webpack-chain instance, say `config`, and passes it through each flow to manipulate. A `flow` is a function which takes `context` (which you can use to access `config`) as argument, it could also be a higher order function if your flow needs options (most likely it does).\n\n### flow\n\nAn example flow which defines some constants:\n\n```diff\n+ function defineConstants(constants) {\n+   return context =\u003e {\n+     context.config.plugin('define-constants')\n+       .use(context.webpack.DefinePlugin, [stringifyObjValue(constants)])\n+   }\n+ }\n\nfunction stringifyObjValue(obj) {\n  return Object.keys(obj).reduce((res, key) =\u003e {\n    res[key] = JSON.stringify(obj[key])\n    return res\n  }, {})\n}\n\n+ // Then use it\n+ flow.createConfig([\n+   defineConstants({\n+     'process.env.NODE_ENV': 'development'\n+   })\n+ ])\n```\n\n## Install\n\n```bash\nyarn add webpack-flow\n```\n\n## Usage\n\n```js\n// webpack.config.js\nconst flow = require('webpack-flow')\n\nmodule.exports = flow.createConfig([\n  flow.entry('src/index.js'),\n  //...\n])\n```\n\nFor more usages please head to [documentations](./docs).\n\n## Contributing\n\n1. Fork it!\n2. Create your feature branch: `git checkout -b my-new-feature`\n3. Commit your changes: `git commit -am 'Add some feature'`\n4. Push to the branch: `git push origin my-new-feature`\n5. Submit a pull request :D\n\n\n## Author\n\n**webpack-flow** © [egoist](https://github.com/egoist), Released under the [MIT](./LICENSE) License.\u003cbr\u003e\nAuthored and maintained by egoist with help from contributors ([list](https://github.com/egoist/webpack-flow/contributors)).\n\n\u003e [egoistian.com](https://egoistian.com) · GitHub [@egoist](https://github.com/egoist) · Twitter [@rem_rin_rin](https://twitter.com/rem_rin_rin)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fwebpack-flow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fegoist%2Fwebpack-flow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fegoist%2Fwebpack-flow/lists"}