{"_id":"stylus-loader@9.1.0","bugs":{"url":"https://github.com/webpack/stylus-loader/issues"},"dist":{"shasum":"7db08d46470e20b1949a8915a3e1ec9b266dd8a0","tarball":"http://registry-npm.ywwl.com/stylus-loader/download/stylus-loader-9.1.0.tgz","fileCount":12,"integrity":"sha512-++TkHIlmKicwAVwJNU60l0H/MomtfGr0249JO2Y/ikjc3RIycpFtOfBQ+fgaxl2dh6aHwslg5G/vlIVXGMThSg==","signatures":[{"sig":"MEYCIQCqVDISwOxnNnxoW3SaITrTYfTAsfnGai7ClStflaEo4QIhAK2mccvO3AR+qvc7J9ZwUSvQtPa/tTV7+VTQ70hnSsUn","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIB+nUL13POReC6Zg+fnCTyDgVN5WHocZ4i9snv3ArIuZAiAK4c6HFKubODaTsBCQbvFHc3dSjgEL8UE2ACDHxC+YQQ=="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/stylus-loader@9.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":105411,"size":18360,"noattachment":false,"key":"/stylus-loader/-/stylus-loader-9.1.0.tgz"},"main":"./dist/cjs/index.js","name":"stylus-loader","type":"module","types":"./types/index.d.ts","author":{"url":"http://dontkry.com","name":"Kyle Robinson Young","email":"kyle@dontkry.com"},"module":"./dist/esm/index.js","engines":{"node":">= 22.11.0"},"exports":{".":{"types":"./types/index.d.ts","import":"./dist/esm/index.js","default":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"./package.json":"./package.json"},"funding":{"url":"https://opencollective.com/webpack","type":"opencollective"},"gitHead":"57f3c7f93ebf91036c446eb45b9347c1eff3d816","license":"MIT","scripts":{"fix":"npm run fix:code && npm run fmt","fmt":"npm run fmt:check -- --write","lint":"npm-run-all -l -p \"lint:**\" && npm run fmt:check","test":"npm run test:base -- \"test/*.test.js\"","build":"npm-run-all -p \"build:*\"","clean":"del-cli dist types","prepare":"husky && npm run build","pretest":"npm run lint","release":"npm run build && changeset publish","version":"changeset version","fix:code":"npm run lint:code -- --fix","prebuild":"npm run clean","security":"npm audit --production","build:cjs":"babel src -d dist/cjs --env-name cjs --copy-files --no-copy-ignored && node -e \"const fs=require('fs');fs.writeFileSync('dist/cjs/package.json','{\\\"type\\\":\\\"commonjs\\\"}\\n');fs.appendFileSync('dist/cjs/index.js','module.exports = exports.default;\\nmodule.exports.default = exports.default;\\n')\"","build:esm":"babel src -d dist/esm --env-name esm --copy-files --no-copy-ignored","fmt:check":"prettier --list-different --cache --ignore-unknown .","lint:code":"eslint --cache .","test:base":"node --import ./test/setup-snapshots.js --test --test-force-exit --test-reporter=dot --test-reporter-destination=stdout --experimental-test-module-mocks","lint:types":"tsc --pretty --noEmit","build:types":"tsc && prettier \"types/**/*.ts\" --write","lint:spelling":"cspell --cache --no-must-find-files --quiet \"**/*.*\"","test:coverage":"npm run test:base -- --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage.lcov --test-coverage-include=\"src/**/*.js\" \"test/*.test.js\""},"version":"9.1.0","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"765a35ff-73b9-41fe-a273-2a0288987f28"}},"homepage":"https://github.com/webpack/stylus-loader","keywords":["webpack","loader","stylus"],"repository":{"url":"git+https://github.com/webpack/stylus-loader.git","type":"git"},"_npmVersion":"11.19.0","description":"Stylus loader for webpack","directories":{},"maintainers":[{"name":"evilebottnawi","email":"sheo13666q@gmail.com"},{"name":"sokra","email":"tobias.koppers@googlemail.com"},{"name":"jhnns","email":"mail@johannesewald.de"},{"name":"15000621931","email":"784487301@qq.com"},{"name":"ev1stensberg","email":"evenstensberg@gmail.com"},{"name":"__hai","email":"haijie0619@gmail.com"},{"name":"avivkeller","email":"me@aviv.sh"}],"_nodeVersion":"24.21.0","dependencies":{"tinyglobby":"^0.2.12","@types/stylus":"^0.48.43","normalize-path":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"del":"^8.0.1","nib":"^1.1.2","husky":"^9.1.3","memfs":"^4.9.3","cspell":"^10.0.0","eslint":"^9.32.0","stylus":"^0.64.0","del-cli":"^7.0.0","webpack":"^5.101.0","prettier":"^3.3.2","benchmark":"^2.1.4","@babel/cli":"^7.24.7","css-loader":"^7.1.2","raw-loader":"^4.0.2","typescript":"^6.0.3","@babel/core":"^7.29.6","@types/node":"^22.19.19","lint-staged":"^17.0.5","npm-run-all":"^4.1.5","style-loader":"^4.0.0","bootstrap-styl":"^5.0.9","@changesets/cli":"^2.30.0","@babel/preset-env":"^7.24.7","@types/normalize-path":"^3.0.2","eslint-config-webpack":"^4.4.2","@changesets/get-github-info":"^0.8.0"},"peerDependencies":{"stylus":">=0.52.4","webpack":"^5.0.0","@rspack/core":"0.x || ^1.0.0 || ^2.0.0-0"},"peerDependenciesMeta":{"webpack":{"optional":true},"@rspack/core":{"optional":true}},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/stylus-loader_9.1.0_1793122550703_0.22297204566262918"},"readme":"<div align=\"center\">\n  <a href=\"https://github.com/webpack/webpack\">\n    <img width=\"200\" height=\"200\" src=\"https://webpack.js.org/assets/icon-square-big.svg\">\n  </a>\n</div>\n\n[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![tests][tests]][tests-url]\n[![cover][cover]][cover-url]\n[![discussion][discussion]][discussion-url]\n[![size][size]][size-url]\n\n# stylus-loader\n\nA Stylus loader for webpack. Compiles Stylus files into CSS.\n\n## Getting Started\n\nTo begin, you'll need to install `stylus` and `stylus-loader`:\n\n```console\nnpm install stylus stylus-loader --save-dev\n```\n\nor\n\n```console\nyarn add -D stylus stylus-loader\n```\n\nor\n\n```console\npnpm add -D stylus stylus-loader\n```\n\nThen add the loader to your `webpack` configuration. For example:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        // Uses the built-in CSS support of webpack, i.e. `.module.styl` files\n        // are treated as CSS modules, other files are treated as plain CSS\n        type: \"css/auto\",\n        // Compiles Stylus to CSS\n        use: [\"stylus-loader\"],\n      },\n    ],\n  },\n  experiments: {\n    // Enables the built-in CSS support of webpack\n    css: true,\n  },\n};\n```\n\n> [!NOTE]\n>\n> The built-in CSS support of webpack requires `experiments.css` to be enabled.\n> Alternatively you can still chain the loader with [`css-loader`](https://github.com/webpack/css-loader) and [`style-loader`](https://github.com/webpack/style-loader) (or the [`mini-css-extract-plugin`](https://github.com/webpack/mini-css-extract-plugin)), see [Using `css-loader` and `style-loader`](#using-css-loader-and-style-loader).\n\nFinally, run `webpack` using the method you normally use (e.g., via CLI or an npm script).\n\n## Options\n\n- **[`stylusOptions`](#stylusOptions)**\n- **[`sourceMap`](#sourcemap)**\n- **[`webpackImporter`](#webpackimporter)**\n- **[`additionalData`](#additionalData)**\n- **[`implementation`](#implementation)**\n\n### `stylusOptions`\n\nType:\n\n```ts\ntype stylusOptions =\n  | {\n      use: (string | ((stylusOptions: StylusOptions) => void))[];\n      include: string[];\n      import: string[];\n      define: any[];\n      includeCSS: false;\n      resolveURL: boolean | object;\n      lineNumbers: boolean;\n      hoistAtrules: boolean;\n      compress: boolean;\n    }\n  | ((loaderContext: LoaderContext) => string[]);\n```\n\nDefault: `{}`\n\nYou can pass any Stylus specific options to the `stylus-loader` through the `stylusOptions` property in the [loader options](https://webpack.js.org/configuration/module/#ruleoptions--rulequery).\n\nSee the [Stylus documentation](https://stylus-lang.com/docs/js.html).\n\nOptions in dash-case should be written in camelCase.\n\n#### `object`\n\nUse an object to pass options through to Stylus.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              stylusOptions: {\n                // eslint-disable-next-line jsdoc/no-restricted-syntax\n                /**\n                 * Specify Stylus plugins to use. Plugins may be passed as\n                 * strings instead of importing them in your Webpack config.\n                 * @type {(string | (renderer: object) => void)[]}\n                 * @default []\n                 */\n                use: [\"nib\"],\n\n                /**\n                 * Add path(s) to the import lookup paths.\n                 * @type {string[]}\n                 * @default []\n                 */\n                include: [path.join(__dirname, \"src/styl/config\")],\n\n                /**\n                 * Import the specified Stylus files/paths.\n                 * @type {string[]}\n                 * @default []\n                 */\n                import: [\"nib\", path.join(__dirname, \"src/styl/mixins\")],\n\n                /**\n                 * Define Stylus variables or functions.\n                 * @type {[string, string | number | boolean, boolean?] | Record<string, string | number | boolean>}\n                 * @default {}\n                 */\n                // Array is the recommended syntax: [key, value, raw]\n                define: [\n                  [\"$development\", process.env.NODE_ENV === \"development\"],\n                  [\"rawVar\", 42, true],\n                ],\n                // Object is deprecated syntax (there is no possibility to specify \"raw')\n                // define: {\n                //   $development: process.env.NODE_ENV === 'development',\n                //   rawVar: 42,\n                // },\n\n                /**\n                 * Include regular CSS on \\@import.\n                 * @type {boolean}\n                 * @default false\n                 */\n                includeCSS: false,\n\n                /**\n                 * Resolve relative url()'s inside imported files.\n                 * @see https://stylus-lang.com/docs/js.html#stylusresolveroptions\n                 * @type {boolean | { nocheck?: boolean, paths?: string[] }}\n                 * @default { nocheck: true }\n                 */\n                resolveURL: true,\n                // resolveURL: { nocheck: true },\n\n                /**\n                 * Emits comments in the generated CSS indicating the corresponding Stylus line.\n                 * @see https://stylus-lang.com/docs/executable.html\n                 * @type {boolean}\n                 * @default false\n                 */\n                lineNumbers: true,\n\n                /**\n                 * Move \\@import and \\@charset to the top.\n                 * @see https://stylus-lang.com/docs/executable.html\n                 * @type {boolean}\n                 * @default false\n                 */\n                hoistAtrules: true,\n\n                /**\n                 * Compress CSS output.\n                 * In the \"production\" mode is `true` by default\n                 * @see https://stylus-lang.com/docs/executable.html\n                 * @type {boolean}\n                 * @default false\n                 */\n                compress: true,\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n#### `function`\n\nAllows setting the options passed through to Stylus based off of the loader context.\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              stylusOptions: (loaderContext) => {\n                // More information about available properties https://webpack.js.org/api/loaders/\n                const { resourcePath, rootContext } = loaderContext;\n                const relativePath = path.relative(rootContext, resourcePath);\n\n                if (relativePath === \"styles/foo.styl\") {\n                  return {\n                    paths: [\"absolute/path/c\", \"absolute/path/d\"],\n                  };\n                }\n\n                return {\n                  paths: [\"absolute/path/a\", \"absolute/path/b\"],\n                };\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `sourceMap`\n\nType:\n\n```ts\ntype sourceMap = boolean;\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              sourceMap: true,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `webpackImporter`\n\nType:\n\n```ts\ntype webpackImporter = boolean;\n```\n\nDefault: `true`\n\nEnables/disables the default Webpack importer.\n\nThis can improve performance in some cases.\nUse it with caution because aliases and `@import` at-rules starting with `~` will not work.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              webpackImporter: false,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `additionalData`\n\nType:\n\n```ts\ntype additionalData =\n  | string\n  | ((\n      content: string | Buffer,\n      loaderContext: LoaderContext,\n      meta: any,\n    ) => string);\n```\n\nDefault: `undefined`\n\nPrepends `Stylus` code before the actual entry file.\nIn this case, the `stylus-loader` will not override the source but will simply **prepend** the entry's content.\n\nThis is especially useful when some of your Stylus variables depend on the environment.\n\n> [!NOTE]\n>\n> Since you're injecting code, this will break the source mappings in your entry file.\n> Often there's a simpler solution than this, such as using multiple Stylus entry files.\n\n#### `string`\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              additionalData: `@env: ${process.env.NODE_ENV};`,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n#### `function`\n\n##### Sync\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              additionalData: (content, loaderContext) => {\n                // More information about available properties https://webpack.js.org/api/loaders/\n                const { resourcePath, rootContext } = loaderContext;\n                const relativePath = path.relative(rootContext, resourcePath);\n\n                if (relativePath === \"styles/foo.styl\") {\n                  return `value = 100px${content}`;\n                }\n\n                return `value = 200px${content}`;\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n##### Async\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              additionalData: async (content, loaderContext) => {\n                // More information about available properties https://webpack.js.org/api/loaders/\n                const { resourcePath, rootContext } = loaderContext;\n                const relativePath = path.relative(rootContext, resourcePath);\n\n                if (relativePath === \"styles/foo.styl\") {\n                  return `value = 100px${content}`;\n                }\n\n                return `value = 200px${content}`;\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### `implementation`\n\nType:\n\n```ts\ntype implementation = (() => typeof import(\"stylus\")) | string;\n```\n\nThe `implementation` option allows you to specify which `Stylus implementation` to use.\nIt overrides the locally installed `peerDependency` version of `stylus`.\n\n#### `function`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              implementation: require(\"stylus\"),\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n#### `string`\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              implementation: require.resolve(\"stylus\"),\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n## Examples\n\n### Normal Usage\n\nSet the module `type` to `css/auto` and enable `experiments.css` to let webpack handle the generated CSS with its built-in CSS support, without any extra loaders or plugins.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\", // Handles the generated CSS using the built-in CSS support of webpack\n        use: [\"stylus-loader\"], // Compiles Stylus to CSS\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\nThe `css/auto` module type treats `*.module.styl` files as [CSS modules](#css-modules) and any other file as plain CSS.\nUse `type: \"css\"` to always treat the file as plain CSS, or `type: \"css/module\"` to always treat it as a CSS module.\n\n### Using `css-loader` and `style-loader`\n\nThe built-in CSS support of webpack is not mandatory, you can still chain the `stylus-loader` with [`css-loader`](https://github.com/webpack/css-loader) and [`style-loader`](https://github.com/webpack/style-loader) to immediately apply all styles to the DOM.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        use: [\n          {\n            loader: \"style-loader\", // Creates style nodes from JS strings\n          },\n          {\n            loader: \"css-loader\", // Translates CSS into CommonJS\n          },\n          {\n            loader: \"stylus-loader\", // Compiles Stylus to CSS\n          },\n        ],\n      },\n    ],\n  },\n};\n```\n\nNote that in this case the `type` and `experiments.css` options should not be set for this rule, and options like `sourceMap` have to be enabled for the `css-loader` too.\n\n### Source maps\n\nTo enable sourcemaps for CSS, you'll need to pass the `sourceMap` property in the loader's options.\nIf this is not passed, the loader will respect the setting for webpack source maps, set in `devtool`.\n\n**webpack.config.js**\n\n```javascript\nmodule.exports = {\n  devtool: \"source-map\", // any \"source-map\"-like devtool is possible\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              sourceMap: true,\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### Using nib with stylus\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              stylusOptions: {\n                use: [require(\"nib\")()],\n                import: [\"nib\"],\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### Import JSON files\n\nStylus does not provide resolving capabilities in the `json()` function.\nTherefore webpack resolver does not work for `.json` files.\nTo handle this, use a [`stylus resolver`](#stylus-resolver).\n\n**index.styl**\n\n```styl\n// Suppose the file is located here `node_modules/vars/vars.json`\njson('vars.json')\n\n@media queries-small\n  body\n    display nope\n\n```\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              stylusOptions: {\n                // Specify the path. where to find files\n                paths: [\"node_modules/vars\"],\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### In production\n\nThe built-in CSS support of webpack always extracts style sheets into dedicated files, so your styles are not dependent on JavaScript, which improves performance and cacheability.\nThe name of the generated files can be configured using the [`output.cssFilename`](https://webpack.js.org/configuration/output/#outputcssfilename) and [`output.cssChunkFilename`](https://webpack.js.org/configuration/output/#outputcsschunkfilename) options.\n\nWhen you chain the loader with `css-loader` and `style-loader` instead, it's recommended to extract the style sheets into a dedicated CSS file in production using the [MiniCssExtractPlugin](https://github.com/webpack/mini-css-extract-plugin). This way your styles are not dependent on JavaScript.\n\n### webpack resolver\n\nWebpack provides an [advanced mechanism to resolve files](https://webpack.js.org/configuration/resolve/).\nThe `stylus-loader` applies the webpack resolver when processing queries.\nThus you can import your Stylus modules directly from `node_modules`.\n\n```styl\n@import 'bootstrap-styl/bootstrap/index.styl';\n```\n\nUsing `~` prefix is deprecated and can be removed from your code (**we recommended**), but we still support it for historical reasons.\n\nWhy you can removed it? The loader will first try to resolve `@import`/`@require` as relative, if it cannot be resolved, the loader will try to resolve `@import`/`@require` inside [`node_modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).\n\nJust prepend them with a `~` which tells webpack to look up the [`modules`](https://webpack.js.org/configuration/resolve/#resolvemodules).\n\n```styl\n@import \"~bootstrap-styl/bootstrap/index.styl\";\n```\n\nIt's important to only prepend it with `~`, because `~/` resolves to the home-directory, which is different.\n\nWebpack needs to distinguish between `bootstrap` and `~bootstrap`, because CSS and Stylus files have no special syntax for importing relative files.\n\nWriting `@import \"file\"` is the same as `@import \"./file\";`\n\n### Stylus resolver\n\nIf you specify the `paths` option, modules will be searched in the given `paths`.\nThis is the default Stylus behavior.\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\n          {\n            loader: \"stylus-loader\",\n            options: {\n              stylusOptions: {\n                paths: [path.resolve(__dirname, \"node_modules\")],\n              },\n            },\n          },\n        ],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n### Extracting style sheets\n\nBundling CSS with webpack has some nice advantages like referencing images and fonts with hashed URLs or [hot module replacement](https://webpack.js.org/concepts/hot-module-replacement/) in development.\nIn production, on the other hand, it's not a good idea to apply your style sheets depending on JS execution.\nRendering may be delayed or even a [FOUC](https://en.wikipedia.org/wiki/Flash_of_unstyled_content) might be visible. Thus it's often still better to have them as separate files in your final production build.\n\nThe built-in CSS support of webpack does this out of the box: every entry point and chunk gets its own style sheet, no extra plugin required.\nWhen you chain the loader with the `css-loader` instead, use the [MiniCssExtractPlugin](https://github.com/webpack/mini-css-extract-plugin) to extract a style sheet from the bundle.\n\n### CSS modules\n\nWith the built-in CSS support of webpack, `*.module.styl` files are treated as [CSS modules](https://github.com/css-modules/css-modules) when the module `type` is `css/auto`, and all files are treated as CSS modules when the module `type` is `css/module`:\n\n**webpack.config.js**\n\n```js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.styl$/i,\n        type: \"css/auto\",\n        use: [\"stylus-loader\"],\n      },\n    ],\n  },\n  experiments: {\n    css: true,\n  },\n};\n```\n\n**index.js**\n\n```js\nimport * as styles from \"./style.module.styl\";\n\ndocument.body.className = styles.box;\n```\n\n## Contributing\n\nWe welcome all contributions!\nIf you're new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.\n\n[CONTRIBUTING](https://github.com/webpack/stylus-loader?tab=contributing-ov-file#contributing)\n\n## License\n\n[MIT](./LICENSE)\n\n[npm]: https://img.shields.io/npm/v/stylus-loader.svg\n[npm-url]: https://npmjs.com/package/stylus-loader\n[node]: https://img.shields.io/node/v/stylus-loader.svg\n[node-url]: https://nodejs.org\n[tests]: https://github.com/webpack/stylus-loader/workflows/stylus-loader/badge.svg\n[tests-url]: https://github.com/webpack/stylus-loader/actions\n[cover]: https://codecov.io/gh/webpack/stylus-loader/branch/main/graph/badge.svg\n[cover-url]: https://codecov.io/gh/webpack/stylus-loader\n[discussion]: https://img.shields.io/github/discussions/webpack/webpack\n[discussion-url]: https://github.com/webpack/webpack/discussions\n[size]: https://packagephobia.now.sh/badge?p=stylus-loader\n[size-url]: https://packagephobia.now.sh/result?p=stylus-loader\n","publish_time":1793122550792,"_cnpm_publish_time":1793122550792,"dist-tags":{"latest":"9.1.0","webpack1":"2.5.1"}}