{"id":17159847,"url":"https://github.com/panjiesw/webpack-configs","last_synced_at":"2026-05-04T02:38:50.178Z","repository":{"id":143928179,"uuid":"81481544","full_name":"panjiesw/webpack-configs","owner":"panjiesw","description":"Various commonly used and slightly opinionated shared webpack configurations.","archived":false,"fork":false,"pushed_at":"2017-06-09T18:41:36.000Z","size":45,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-01T11:09:12.058Z","etag":null,"topics":["config","javascript","merge","webpack","webpack2"],"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/panjiesw.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-09T18:29:18.000Z","updated_at":"2017-02-09T18:30:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"4cb8177c-6987-4e33-8daf-a6e15d9975d3","html_url":"https://github.com/panjiesw/webpack-configs","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/panjiesw/webpack-configs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjiesw%2Fwebpack-configs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjiesw%2Fwebpack-configs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjiesw%2Fwebpack-configs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjiesw%2Fwebpack-configs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panjiesw","download_url":"https://codeload.github.com/panjiesw/webpack-configs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panjiesw%2Fwebpack-configs/sbom","scorecard":{"id":719213,"data":{"date":"2025-08-11","repo":{"name":"github.com/panjiesw/webpack-configs","commit":"30ca69f5809f942c70e47d84a41c0d424cb1e86f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/20 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"69 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-832h-xg76-4gv6","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx","Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-9vvw-cc9w-f27h","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-hr2v-3952-633q","Warn: Project is vulnerable to: GHSA-vh7m-p724-62c2","Warn: Project is vulnerable to: GHSA-r9p9-mrjm-926w","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-qrmc-fj45-qfc2","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3","Warn: Project is vulnerable to: MAL-2023-462","Warn: Project is vulnerable to: GHSA-xf7w-r453-m56c","Warn: Project is vulnerable to: GHSA-44pw-h2cw-w3vq","Warn: Project is vulnerable to: GHSA-jp4x-w63m-7wgm","Warn: Project is vulnerable to: GHSA-c429-5p7v-vgjp","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-4hpf-3wq7-5rpr","Warn: Project is vulnerable to: GHSA-f522-ffg8-j8r6","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-282f-qqgm-c34q","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-fvqr-27wr-82fm","Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574","Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-w9mr-4mfr-499f","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-gqgv-6jq5-jjj9","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-6g33-f262-xjp4","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7","Warn: Project is vulnerable to: GHSA-2m39-62fm-q8r3","Warn: Project is vulnerable to: GHSA-mf6x-7mm4-x2g7","Warn: Project is vulnerable to: GHSA-j44m-qm6p-hp7m","Warn: Project is vulnerable to: GHSA-3jfq-g458-7qm9","Warn: Project is vulnerable to: GHSA-5955-9wpr-37jh","Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36","Warn: Project is vulnerable to: GHSA-g7q5-pjjr-gqvp","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-w5p7-h5w8-2hfq","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v","Warn: Project is vulnerable to: GHSA-xc7v-wxcw-j472","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T10:45:23.706Z","repository_id":143928179,"created_at":"2025-08-22T10:45:23.706Z","updated_at":"2025-08-22T10:45:23.706Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32592719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T22:12:39.696Z","status":"online","status_checked_at":"2026-05-04T02:00:06.625Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["config","javascript","merge","webpack","webpack2"],"created_at":"2024-10-14T22:15:17.304Z","updated_at":"2026-05-04T02:38:50.161Z","avatar_url":"https://github.com/panjiesw.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Webpack Configs\n\nVarious slightly opinionated shared webpack configurations to help you survive.\nParticularly useful with tools like [webpack-merge](https://www.npmjs.com/package/webpack-merge).\n\n\u003c!-- TOC --\u003e\n\n- [Webpack Configs](#webpack-configs)\n\t- [Why?](#why)\n\t- [Requirements](#requirements)\n\t- [Installation](#installation)\n\t- [Usage](#usage)\n\t- [Shared Configuration Parts](#shared-configuration-parts)\n\t\t- [`devServer(options?: DevServer)`](#devserveroptions-devserver)\n\t\t- [`javascript(options?: {include?, exclude?, options?})`](#javascriptoptions-include-exclude-options)\n\t\t- [`javascript.lint(options?: {include?, exclude?, options?})`](#javascriptlintoptions-include-exclude-options)\n\t\t- [`javascript.sourcemap()`](#javascriptsourcemap)\n\t\t- [`typescript(options?: {include?, exclude?, options?})`](#typescriptoptions-include-exclude-options)\n\t\t- [`typescript.sourcemap()`](#typescriptsourcemap)\n\t\t- [`typescript.hmr(options?: {include?, exclude?, options?, tsOptions?})`](#typescripthmroptions-include-exclude-options-tsoptions)\n\t\t- [`style(options: {test, include, exclude})`](#styleoptions-test-include-exclude)\n\t\t\t- [`style.css(options?)`](#stylecssoptions)\n\t\t\t- [`style.post(options?)`](#stylepostoptions)\n\t\t\t- [`style.less(options?)`](#stylelessoptions)\n\t\t\t- [`style.sass(options?)`](#stylesassoptions)\n\t\t\t- [Using `extract-text-webpack-plugin`](#using-extract-text-webpack-plugin)\n\t- [Contribution](#contribution)\n\t- [License](#license)\n\n\u003c!-- /TOC --\u003e\n\n## Why?\n\n1. Specifically for my lazy self use case to not repeat common config over and over again.\n2. Maybe for you who have similarly use case as mine.\n3. More composed build.\n\n\n## Requirements\n\n- Node JS \u003e= 6 LTS\n- Webpack \u003e= 2.2.0\n\n## Installation\n\nwith npm\n\n```\nnpm install -D webpack webpack-merge webpack-configs\n```\n\nwith yarn\n\n```\nyarn add -D webpack webpack-configs\n```\n\nThis will not include any loader dependencies used in the shared configurations.\nYou will have to install them separately.\n\n## Usage\n\n```javascript\nconst shared = require('webpack-configs');\n// dev server\nshared.devServer(options);\n// javascript with babel-loader\nshared.javascript(options);\n// javascript linting with eslint-loader\nshared.javascript.lint(options);\n// style loaders\nshared.style(options)\n  .use(shared.style.css({importLoaders: 1}))\n  .use(shared.style.post());\n```\n\nThese configurations are best used with `webpack-merge`.\n\n```javascript\n// webpack.config.js\nconst webpack = require('webpack');\nconst merge = require('webpack-merge');\nconst shared = require('webpack-configs');\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\n\nconst common = merge([\n  {\n    entry: {\n      app: PATHS.app,\n    },\n    output: {\n      path: PATHS.build,\n      filename: '[name].js',\n    },\n    plugins: [\n      new HtmlWebpackPlugin({\n        title: 'Webpack demo',\n      }),\n    ],\n  },\n]);\n\nfunction production() {\n  return merge([\n    common,\n    shared.javascript.lint({ include: PATHS.app }),\n  ]);\n}\n\nfunction development() {\n  return merge([\n    common,\n    {\n      plugins: [\n        new webpack.NamedModulesPlugin(),\n      ],\n    },\n    shared.devServer(),\n    shared.javascript.lint({\n      include: PATHS.app,\n      options: {\n        emitWarning: true,\n      },\n    }),\n  ]);\n}\n\nmodule.exports = function(env) {\n  if (env === 'production') {\n    return production();\n  }\n\n  return development();\n};\n```\n\nSee more about composing webpack configuration in [this SurviveJS page](http://survivejs.com/webpack/developing-with-webpack/composing-configuration/).\n\n## Shared Configuration Parts\n\n### `devServer(options?: DevServer)`\n\nReturns webpack configuration which include `devServer` and `webpack.HotModuleReplacementPlugin`.\n\n- [optional] `options` - [DevServer](https://webpack.js.org/configuration/dev-server/) options with some defaults set below\n  - `host` - use `process.env.HOST` if set, or webpack defaults otherwise (`'localhost'`)\n  - `port` - use `process.env.PORT` if set, or webpack defaults otherwise (`8080`)\n  - `historyApiFallback` - defaults to `true`\n  - `stats` - defaults to `'errors-only'`\n  - `publicPath` - defaults to `'/'`\n  - `contentBase` - defaults to `public` dir relative to `process.cwd()`\n  - `hotOnly` - defaults to `false`\n  - `hot` - defaults to `false`\n\n```javascript\nshared.devServer() ===\n{\n  devServer: {\n    host: process.env.HOST || 'localhost',\n    port: process.env.PORT || 8080,\n    historyApiFallback: true,\n    stats: 'errors-only',\n    publicPath: '/',\n    contentBase: `${process.cwd()}/public`,\n    hotOnly: true,\n  },\n  plugins: [\n    new webpack.HotModuleReplacementPlugin(),\n  ],\n}\n```\n\n### `javascript(options?: {include?, exclude?, options?})`\n\nReturns webpack configuration which include `module.rules` with `babel-loader`.\n\n_**NOTES**_: You must add `babel-loader` dependency to use this.\n\n- [optional] `options` - [Rule Config](https://webpack.js.org/configuration/module/#rule) to be applied\n  - `exclude` - Resource to [exclude](https://webpack.js.org/configuration/module/#rule-exclude)\n  - `include` - Resource to [include](https://webpack.js.org/configuration/module/#rule-include)\n  - `options` - [Options](https://github.com/babel/babel-loader#options) passed to `babel-loader`\n\n```javascript\nshared.javascript({include: path.resolve(__dirname, 'src')}) ===\n{\n  module: {\n    rules: [{\n      test: /\\.js(x?)$/,\n      loader: 'babel-loader',\n      include: './src'\n    }]\n  }\n}\n```\n\n### `javascript.lint(options?: {include?, exclude?, options?})`\n\nReturns webpack configuration which include `module.rules` with `eslint-loader`.\n\n_**NOTES**_: You must add `eslint-loader` dependency to use this.\n\n- [optional] `options` - [Rule Config](https://webpack.js.org/configuration/module/#rule) to be applied\n  - `exclude` - Resource to [exclude](https://webpack.js.org/configuration/module/#rule-exclude)\n  - `include` - Resource to [include](https://webpack.js.org/configuration/module/#rule-include)\n  - `options` - [Options](https://github.com/MoOx/eslint-loader#options) passed to `eslint-loader`\n\n```javascript\nshared.javascript.lint({include: path.resolve(__dirname, 'src')}) ===\n{\n  module: {\n    rules: [{\n      test: /\\.js(x?)$/,\n      loader: 'eslint-loader',\n      enforce: 'pre',\n      include: './src'\n    }]\n  }\n}\n```\n\n### `javascript.sourcemap()`\n\nAdd sourcemap loader support as mentioned in [Webpack + Typescript Guide](https://webpack.js.org/guides/webpack-and-typescript/#enabling-source-maps)\n\n```javascript\nshared.javascript.sourcemap() ===\n{\n  module: {\n    rules: [{\n      test: /\\.js(x?)$/,\n      enforce: 'pre',\n      use: 'source-map-loader'\n    }]\n  }\n}\n```\n\n### `typescript(options?: {include?, exclude?, options?})`\n\nReturns webpack configuration which include `module.rules` with `awesome-typescript-loader`.\n\n_**NOTES**_: You must add `awesome-typescript-loader` dependency to use this.\n\n- [optional] `options` - [Rule Config](https://webpack.js.org/configuration/module/#rule) to be applied\n  - `exclude` - Resource to [exclude](https://webpack.js.org/configuration/module/#rule-exclude)\n  - `include` - Resource to [include](https://webpack.js.org/configuration/module/#rule-include)\n  - `options` - [Options](https://github.com/s-panferov/awesome-typescript-loader#loader-options) passed to `awesome-typescript-loader`\n\n```javascript\nshared.typescript({include: path.resolve(__dirname, 'src')}) ===\n{\n  module: {\n    rules: [{\n      test: /\\.ts(x?)$/,\n      loader: 'awesome-typescript-loader',\n      include: './src'\n    }]\n  },\n  plugins: [\n    new require('awesome-typescript-loader').CheckerPlugin(),\n    new require('awesome-typescript-loader').TsConfigPathsPlugin()\n  ]\n}\n```\n\n### `typescript.sourcemap()`\n\nAdd sourcemap loader support as mentioned in [Webpack + Typescript Guide](https://webpack.js.org/guides/webpack-and-typescript/#enabling-source-maps)\n\n```javascript\nshared.typescript.sourcemap() ===\n{\n  module: {\n    rules: [{\n      test: /\\.ts(x?)$/,\n      enforce: 'pre',\n      use: 'source-map-loader'\n    }]\n  }\n}\n```\n\n### `typescript.hmr(options?: {include?, exclude?, options?, tsOptions?})`\n\nAdd React Hot Loader 3 into typescript build pipeline.\n\n```javascript\nshared.typescript.hmr() ===\n{\n  module: {\n    rules: [{\n      test: /\\.ts(x?)$/,\n      use: [\n        'react-hot-loader/webpack',\n        {\n          loader: 'awesome-typescript-loader',\n          options: tsOptions,\n        }\n      ],\n    }]\n  }\n}\n```\n\n### `style(options: {test, include, exclude})`\n\nReturns webpack configuration which include `module.rules` with `style-loader`.\n\n_**NOTES**_: You must add `style-loader` dependency to use this.\n\n- **required** `options` - [Rule Config](https://webpack.js.org/configuration/module/#rule) to be applied\n  - `exclude` - Resource to [exclude](https://webpack.js.org/configuration/module/#rule-exclude)\n  - `include` - Resource to [include](https://webpack.js.org/configuration/module/#rule-include)\n  - `test` - Resource [test](https://webpack.js.org/configuration/module/#rule-test)\n- methods:\n  - `use(loader, options?)` - Chain `style-loader` with other commonly used style related loaders.\n      - **required** `loader` - The loader to use, e.g `'css-loader'`. Or one of predefined loaders described below.\n      - [optional] options - Options passed to the loader.\n  - `extract(options?)` - Transform the configuration to use `extract-text-webpack-plugin`. More info [below](#using-extract-text-webpack-plugin).\n      - [optional] options - [Options](https://github.com/webpack-contrib/extract-text-webpack-plugin#options) passed to instantiate the `extract-text-webpack-plugin`.\n\n```javascript\nshared.style({test: /\\.css$/}) ===\n{\n  module: {\n    rules: [{\n      test: /\\.css$/,\n      use: ['style-loader']\n    }]\n  }\n}\n```\n\nYou can chain with other shared style config below to make a `use` style loaders chain, e.g. with prepocessor loader.\n\n_**NOTES**_: The order of chain call matters.\n\n```javascript\nshared.style({test: /\\.css$/}).use(shared.style.css());\n```\n\nBelow are the list of available method to chain\n\n#### `style.css(options?)`\n\nChain `style-loader` with `css-loader`.\n\n_**NOTES**_: You must add `css-loader` dependency to use this.\n\n- [optional] `options` - [Options](https://github.com/webpack-contrib/css-loader#options) for `css-loader`\n\n```javascript\nshared.style({test: /\\.css$/}).use(shared.style.css({modules: true})) ===\n{\n  module: {\n    rules: [{\n      test: /\\.css$/,\n      use: [\n        'style-loader',\n        {\n          loader: 'css-loader',\n          options: {\n            modules: true\n          }\n        }\n      ]\n    }]\n  }\n}\n```\n\n#### `style.post(options?)`\n\nChain `style-loader`, `css-loader`, with `postcss-loader`.\n\n_**NOTES**_: You must add `postcss-loader` dependency to use this. \u003cbr/\u003e\n_**NOTES**_: Because the loader chain matters, you must call this after including `css-loader`.\n\n- [optional] `options` - [Options](https://github.com/postcss/postcss-loader#options for `postcss-loader`\n\n```javascript\nshared.style({test: /\\.css$/})\n  .use(shared.style.css({modules: true}))\n  .use(shared.style.post()) ===\n{\n  module: {\n    rules: [{\n      test: /\\.css$/,\n      use: [\n        'style-loader',\n        {\n          loader: 'css-loader',\n          options: {\n            modules: true\n          }\n        },\n        'postcss-loader'\n      ]\n    }]\n  }\n}\n```\n\n#### `style.less(options?)`\n\nChain `style-loader`, `css-loader`, with `less-loader`.\n\n_**NOTES**_: You must add `less-loader` dependency to use this. \u003cbr/\u003e\n_**NOTES**_: Because the loader chain matters, you must call this after including `css-loader`.\n\n- [optional] `options` - [Options](https://github.com/webpack-contrib/less-loader#options) for `less-loader`\n\n```javascript\nshared.style({test: /\\.css$/})\n  .use(shared.style.css({modules: true}))\n  .use(shared.style.less()) ===\n{\n  module: {\n    rules: [{\n      test: /\\.css$/,\n      use: [\n        'style-loader',\n        {\n          loader: 'css-loader',\n          options: {\n            modules: true\n          }\n        },\n        'less-loader'\n      ]\n    }]\n  }\n}\n```\n\n#### `style.sass(options?)`\n\nChain `style-loader`, `css-loader`, with `sass-loader`.\n\n_**NOTES**_: You must add `sass-loader` dependency to use this. \u003cbr/\u003e\n_**NOTES**_: Because the loader chain matters, you must call this after including `css-loader`.\n\n- [optional] `options` - [Options](https://github.com/jtangelder/sass-loader#examples) for `sass-loader`\n\n```javascript\nshared.style({test: /\\.css$/})\n  .use(shared.style.css({modules: true}))\n  .use(shared.style.sass()) ===\n{\n  module: {\n    rules: [{\n      test: /\\.css$/,\n      use: [\n        'style-loader',\n        {\n          loader: 'css-loader',\n          options: {\n            modules: true\n          }\n        },\n        'sass-loader'\n      ]\n    }]\n  }\n}\n```\n\n#### Using `extract-text-webpack-plugin`\n\nYou can call the `extract` method as the last chain to transform the configuration\nto use `extract-text-webpack-plugin` instead. This will also include the plugin instance\nin `plugins` webpack array.\n\n```javascript\n// You can use styleConfig in other config, e.g for development and test\nconst styleConfig = shared.style({test: /\\.css$/})\n  .use(shared.style.css({modules: true}))\n  .use(shared.style.post())\n  .use(shared.style.sass())\n\n// Then for a specific build config, you want it to use `extract-text-webpack-plugin`\nconst extracted = styleConfig.extract({filename: '[name].[contenthash].css'}) ===\n{\n  module: {\n    rules: [{\n      test: /\\.css$/,\n      loader: ExtractTextPlugin.extract({\n        fallback: 'style-loader',\n        use: [\n          'style-loader',\n          {\n            loader: 'css-loader',\n            options: {\n              modules: true\n            }\n          },\n          'postcss-loader',\n          'sass-loader'\n        ]\n      })\n    }]\n  },\n  // plugins included\n  plugins: [\n    new ExtractTextPlugin({filename: '[name].[contenthash].css'})\n  ]\n}\n```\n\n## Contribution\n\nThe included shared configs are non exhaustive, if you have some configurations you want to share\nplease drop an issue.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanjiesw%2Fwebpack-configs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanjiesw%2Fwebpack-configs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanjiesw%2Fwebpack-configs/lists"}