{"id":21569273,"url":"https://github.com/ecliptic/webpack-blocks-utils","last_synced_at":"2025-04-10T14:06:27.989Z","repository":{"id":124820510,"uuid":"81883694","full_name":"ecliptic/webpack-blocks-utils","owner":"ecliptic","description":"Tiny webpack-blocks helpers","archived":false,"fork":false,"pushed_at":"2017-07-20T18:25:57.000Z","size":118,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-04-09T17:03:55.646Z","etag":null,"topics":["webpack","webpack-blocks"],"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/ecliptic.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":"2017-02-13T23:44:32.000Z","updated_at":"2018-04-11T06:58:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"b80c59d0-45e7-43e6-8da5-e159ff7a5c78","html_url":"https://github.com/ecliptic/webpack-blocks-utils","commit_stats":{"total_commits":37,"total_committers":2,"mean_commits":18.5,"dds":"0.43243243243243246","last_synced_commit":"cf94f196105ea8428114f1de41216dbb6d47cd88"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecliptic%2Fwebpack-blocks-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecliptic%2Fwebpack-blocks-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecliptic%2Fwebpack-blocks-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ecliptic%2Fwebpack-blocks-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ecliptic","download_url":"https://codeload.github.com/ecliptic/webpack-blocks-utils/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248231883,"owners_count":21069422,"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","webpack-blocks"],"created_at":"2024-11-24T11:09:03.028Z","updated_at":"2025-04-10T14:06:27.961Z","avatar_url":"https://github.com/ecliptic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webpack-blocks-utils\n\nTiny helpers for [webpack-blocks](https://github.com/andywer/webpack-blocks).\n\n[![NPM Version](https://img.shields.io/npm/v/webpack-blocks-utils.svg)](https://www.npmjs.com/package/webpack-blocks-utils)\n[![CircleCI](https://circleci.com/gh/ecliptic/webpack-blocks-utils.svg?style=shield\u0026circle-token=:circle-token)](https://circleci.com/gh/ecliptic/webpack-blocks-utils)\n[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n\n*Version compatibility:*\n\n* webpack-blocks v0._x_ -\u003e webpack-blocks-utils [v1._x_](https://github.com/ecliptic/webpack-blocks-utils/tree/master) (@latest)\n* webpack-blocks v1._x_ -\u003e webpack-blocks-utils [v2._x_](https://github.com/ecliptic/webpack-blocks-utils) (@next)\n\n## Installation\n\n```sh\nyarn add --dev webpack-blocks-utils\n```\n\nor\n\n```sh\nnpm install --save-dev webpack-blocks-utils\n```\n\n## Usage\n\n### setTarget(target)\n\nSets [target](https://webpack.github.io/docs/configuration.html#target)\n\nExample usage:\n\n```js\nsetTarget('electron-renderer')\n```\n\n### setNode(node)\n\nSets [node](https://webpack.github.io/docs/configuration.html#node)\n\nExample usage:\n\n```js\nsetNode({\n  __dirname: false,\n  __filename: false,\n})\n```\n\n### setExternals(externals)\n\nSets [externals](https://webpack.github.io/docs/configuration.html#externals)\n\nExample usage:\n\n```js\nsetExternals(['firebase', 'electron-debug', 'debug'])\n```\n\n### envVar(key, value, configSetters)\n\nApplies an array of webpack blocks only if `process.env[key]` matches the given\n`value`.\n\n```js\nenvVar('ELECTRON', 'true', [\n  setTarget('electron-main'),\n  setExternals(['firebase', 'electron-debug', 'debug']),\n  // ...\n]),\n```\n\n### noParse(regexes)\n\nSets [module.noParse](https://webpack.github.io/docs/configuration.html#module.noParse)\n\nExample usage:\n\n```js\nnoParse([\n  // Don't parse localforage because it's pre-built\n  new RegExp('node_modules/localforage/dist/localforage.js'),\n]),\n```\n\n## Copy Plugin\n\nThe `copy`, `copyPattern`, and `copyOptions` blocks wrap [copy-webpack-plugin](https://github.com/kevlened/copy-webpack-plugin).\n\nThe most basic way to use the plugin is to import `copy` and use it to define simple *from*, *to* pairs that are added to the list of patterns used when the plugin is instantiated.\n\n```js\nimport {createConfig, entryPoint, setOutput} from '@webpack-blocks/webpack2'\nimport babel from '@webpack-blocks/babel6'\nimport {copy} from 'webpack-blocks-utils'\n\nexport default createConfig([\n  entryPoint(['babel-polyfill', './src/Main.js']),\n  setOutput('./build/bundle.js'),\n  babel(),\n  copy('assets/robots.txt', 'robots.txt'),\n  copy('assets/favicon.ico', 'favicon.ico'),\n])\n```\n\nThis would result in the following copy plugin config:\n\n```js\nnew CopyWebpackPlugin([\n  {from: 'assets/robots.txt', to: 'robots.txt'},\n  {from: 'assets/favicon.ico', to: 'favicon.ico'},\n])\n```\n\n### Advanced patterns\n\nIf you need to use more advanced patterns, described [here](https://github.com/kevlened/copy-webpack-plugin#pattern-properties), use the `copyPattern` function:\n\n```js\nimport {createConfig} from '@webpack-blocks/webpack2'\nimport {copyPattern} from 'webpack-blocks-utils'\n\nexport default createConfig([\n  copyPattern({\n    context: 'from/directory',\n    from: '**/*',\n    to: '/absolute/path',\n  }),\n])\n```\n\n### Options\n\nIf you need to set options, use the `copyOptions` function:\n\n```js\nimport {createConfig} from '@webpack-blocks/webpack2'\nimport {copyOptions} from 'webpack-blocks-utils'\n\nexport default createConfig([\n  copyOptions({copyUnmodified: true}),\n])\n```\n\nSee the options list [here](https://github.com/kevlened/copy-webpack-plugin#available-options).\n\n## Html Plugin\n\n```js\nimport {createConfig, entryPoint, setOutput} from '@webpack-blocks/webpack2'\nimport babel from '@webpack-blocks/babel6'\nimport html from './src/webpack-block-html'\n\nexport default createConfig([\n  entryPoint(['babel-polyfill', './src/Main.js']),\n  setOutput('./build/bundle.js'),\n  babel(),\n  html({template: 'assets/index.html'}),\n])\n```\n\n## Options\n\nSee the options list [here](https://github.com/jantimon/html-webpack-plugin#configuration).\n\nDefaults:\n\n* *filename:* 'index.html'\n* *template:* 'templates/index.html'\n* *showErrors:* false\n\n# License\n\nThis project is licensed under [MIT](https://github.com/ecliptic/webpack-blocks-utils/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecliptic%2Fwebpack-blocks-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fecliptic%2Fwebpack-blocks-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fecliptic%2Fwebpack-blocks-utils/lists"}