<div align="center">
<a href="https://github.com/webpack/webpack">
<img width="200" height="200" src="https://webpack.js.org/assets/icon-square-big.svg">
</a>
</div>
[![npm][npm]][npm-url]
[![node][node]][node-url]
[![deps][deps]][deps-url]
[![tests][tests]][tests-url]
[![cover][cover]][cover-url]
[![chat][chat]][chat-url]
[![size][size]][size-url]
# stylus-loader
A Stylus loader for webpack. Compiles Styl to CSS.
## Getting Started
To begin, you'll need to install `stylus` and `stylus-loader`:
```console
$ npm install stylus stylus-loader --save-dev
```
Then add the loader to your `webpack` config. For example:
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.styl$/,
loader: "stylus-loader", // compiles Styl to CSS
},
],
},
};
```
And run `webpack` via your preferred method.
## Options
| Name | Type | Default | Description |
| :---------------------------------------: | :------------------: | :----------------: | :------------------------------------------------------- |
| **[`stylusOptions`](#stylusOptions)** | `{Object\|Function}` | `{}` | Options for Stylus. |
| **[`sourceMap`](#sourcemap)** | `{Boolean}` | `compiler.devtool` | Enables/Disables generation of source maps. |
| **[`webpackImporter`](#webpackimporter)** | `{Boolean}` | `true` | Enables/Disables the default Webpack importer. |
| **[`additionalData`](#additionalData)** | `{String\|Function}` | `undefined` | Prepends/Appends `Stylus` code to the actual entry file. |
### `stylusOptions`
Type: `Object|Function`
Default: `{}`
You can pass any Stylus specific options to the `stylus-loader` through the `stylusOptions` property in the [loader options](https://webpack.js.org/configuration/module/#rule-options-rule-query).
See the [Stylus documentation](https://stylus-lang.com/docs/js.html).
Options in dash-case should use camelCase.
#### `Object`
Use an object to pass options through to Stylus.
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.styl$/,
use: [
{
loader: "style-loader",
},
{
loader: "css-loader",
},
{
loader: "stylus-loader",
options: {
stylusOptions: {
/**
* Specify Stylus plugins to use. Plugins may be passed as
* strings instead of importing them in your Webpack config.
*
* @type {(string|Function)[]}
* @default []
*/
use: ["nib"],
/**
* Add path(s) to the import lookup paths.
*
* @type {string[]}
* @default []
*/
include: [path.join(__dirname, "src/styl/config")],
/**
* Import the specified Stylus files/paths.
*
* @type {string[]}
* @default []
*/
import: ["nib", path.join(__dirname, "src/styl/mixins")],
/**
* Define Stylus variables or functions.
*
* @type {Array|Object}
* @default {}
*/
// Array is the recommended syntax: [key, value, raw]
define: [
["$development", process.env.NODE_ENV === "development"],
["rawVar", 42, true],
],
// Object is deprecated syntax (there is no possibility to specify "raw')
// define: {
// $development: process.env.NODE_ENV === 'development',
// rawVar: 42,
// },
/**
* Include regular CSS on @import.
*
* @type {boolean}
* @default false
*/
includeCSS: false,
/**
* Resolve relative url()'s inside imported files.
*
* @see https://stylus-lang.com/docs/js.html#stylusresolveroptions
*
* @type {boolean|Object}
* @default { nocheck: true }
*/
resolveURL: true,
// resolveURL: { nocheck: true },
/**
* Emits comments in the generated CSS indicating the corresponding Stylus line.
*
* @see https://stylus-lang.com/docs/executable.html
*
* @type {boolean}
* @default false
*/
lineNumbers: true,
/**
* Move @import and @charset to the top.
*
* @see https://stylus-lang.com/docs/executable.html
*
* @type {boolean}
* @default false
*/
hoistAtrules: true,
/**
* Compress CSS output.
* In the "production" mode is `true` by default
*
* @see https://stylus-lang.com/docs/executable.html
*
* @type {boolean}
* @default false
*/
compress: true,
},
},
},
],
},
],
},
};
```
#### `Function`
Allows setting the options passed through to Stylus based off of the loader context.
```js
module.exports = {
module: {
rules: [
{
test: /\.styl/,
use: [
"style-loader",
"css-loader",
{
loader: "stylus-loader",
options: {
stylusOptions: (loaderContext) => {
// More information about available properties https://webpack.js.org/api/loaders/
const { resourcePath, rootContext } = loaderContext;
const relativePath = path.relative(rootContext, resourcePath);
if (relativePath === "styles/foo.styl") {
return {
paths: ["absolute/path/c", "absolute/path/d"],
};
}
return {
paths: ["absolute/path/a", "absolute/path/b"],
};
},
},
},
],
},
],
},
};
```
### `sourceMap`
Type: `Boolean`
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.styl$/i,
use: [
"style-loader",
{
loader: "css-loader",
options: {
sourceMap: true,
},
},
{
loader: "stylus-loader",
options: {
sourceMap: true,
},
},
],
},
],
},
};
```
### `webpackImporter`
Type: `Boolean`
Default: `true`
Enables/Disables the default Webpack importer.
This can improve performance in some cases.
Use it with caution because aliases and `@import` at-rules starting with `~` will not work.
**webpack.config.js**
```js
module.exports = {
module: {
rules: [
{
test: /\.styl/i,
use: [
"style-loader",
"css-loader",
{
loader: "stylus-loader",
options: {
webpackImporter: false,
},
},
],
},
],
},
};
```
### `additionalData`
Type: `String|Function`
Default: `undefined`
Prepends `Stylus` code before the actual entry file.
In this case, the `stylus-l
没有合适的资源?快使用搜索试试~ 我知道了~
coderwhy新课Vue3+TypeScript课堂资料
共7694个文件
ts:1645个
vue:605个
js:536个
需积分: 26 4 下载量 104 浏览量
2022-08-09
15:55:53
上传
评论 1
收藏 43.32MB 7Z 举报
温馨提示
coderwhy新课Vue3+TypeScript课堂资料
资源推荐
资源详情
资源评论
收起资源包目录
coderwhy新课Vue3+TypeScript课堂资料 (7694个子文件)
001f94aff1448c69f04b6265f938165eb1023f 4KB
0047d74d3f9322429b0386483b4afa2a69cbf6 532B
0123ac67f09dc48cb7c85e78c8d7a251941962 10KB
01f2f45697126dc2aec3596cb595fbeb2d53f4 92B
0206baa003f7d230b029fd071bf1abf1c801b7 7KB
020f6c179ae944dd723b64607275d8475cd21a 748B
0248825e5d8428a6c7e59bb4d76aaef22dbe0d 3KB
029bf09e9c81181b6c8092fdec593ef24ae975 947B
029bf09e9c81181b6c8092fdec593ef24ae975 947B
029bf09e9c81181b6c8092fdec593ef24ae975 947B
029bf09e9c81181b6c8092fdec593ef24ae975 947B
029bf09e9c81181b6c8092fdec593ef24ae975 947B
029bf09e9c81181b6c8092fdec593ef24ae975 947B
029bf09e9c81181b6c8092fdec593ef24ae975 947B
029bf09e9c81181b6c8092fdec593ef24ae975 947B
029bf09e9c81181b6c8092fdec593ef24ae975 947B
029bf09e9c81181b6c8092fdec593ef24ae975 947B
02b3a6fd270ac09c676fb5d681ed36603a14c4 160B
02fd3bd982b42a73686843207fff324b4abea2 211B
02fd3bd982b42a73686843207fff324b4abea2 211B
02fd3bd982b42a73686843207fff324b4abea2 211B
02fd3bd982b42a73686843207fff324b4abea2 211B
02fd3bd982b42a73686843207fff324b4abea2 211B
02fd3bd982b42a73686843207fff324b4abea2 211B
02fd3bd982b42a73686843207fff324b4abea2 211B
02fd3bd982b42a73686843207fff324b4abea2 211B
02fd3bd982b42a73686843207fff324b4abea2 211B
02fd3bd982b42a73686843207fff324b4abea2 211B
0306b040e92d9daed988177a077ea4e6c79471 402B
0351f64d7d6637005a4f56f625b75fea39177d 5KB
03c54064f5f3a582d27289bd4a9594fca5ff33 502B
03f1e905a4a5aa7331a6448a19934f8337bf51 173B
03f1e905a4a5aa7331a6448a19934f8337bf51 173B
03f1e905a4a5aa7331a6448a19934f8337bf51 173B
03f1e905a4a5aa7331a6448a19934f8337bf51 173B
03f1e905a4a5aa7331a6448a19934f8337bf51 173B
0410141e457dc6edd0a224e236bc782efebe27 340B
043929894acb25a698ee62b0733f1d8d0185cc 254B
044ad408e9bff6ec421751f6a57416eea62d2c 453B
0462c755326dd848edf0da961d0e50e6edeab5 103B
0462c755326dd848edf0da961d0e50e6edeab5 103B
0462c755326dd848edf0da961d0e50e6edeab5 103B
0462c755326dd848edf0da961d0e50e6edeab5 103B
0462c755326dd848edf0da961d0e50e6edeab5 103B
0462c755326dd848edf0da961d0e50e6edeab5 103B
0462c755326dd848edf0da961d0e50e6edeab5 103B
0462c755326dd848edf0da961d0e50e6edeab5 103B
0462c755326dd848edf0da961d0e50e6edeab5 103B
0462c755326dd848edf0da961d0e50e6edeab5 103B
04a0d6f3fd2c547fa79d5830b951f1b04ef2eb 6KB
04a43e2f31b64cd6468148621702f8af3c7858 137B
04a43e2f31b64cd6468148621702f8af3c7858 137B
04a43e2f31b64cd6468148621702f8af3c7858 137B
04a43e2f31b64cd6468148621702f8af3c7858 137B
04a43e2f31b64cd6468148621702f8af3c7858 137B
04a43e2f31b64cd6468148621702f8af3c7858 137B
04a43e2f31b64cd6468148621702f8af3c7858 137B
04a43e2f31b64cd6468148621702f8af3c7858 137B
04a43e2f31b64cd6468148621702f8af3c7858 137B
04a43e2f31b64cd6468148621702f8af3c7858 137B
06b1b14609e9a37091fb64fe4916b099d760e6 284B
070d384e9a06a6db480f815738a491397ac979 2KB
080ea107e565aa331ce92252b8d9079f2a165a 917B
0875788b7696b6b70dbfb8fff38651b073b295 141B
0875788b7696b6b70dbfb8fff38651b073b295 141B
0875788b7696b6b70dbfb8fff38651b073b295 141B
0875788b7696b6b70dbfb8fff38651b073b295 141B
0875788b7696b6b70dbfb8fff38651b073b295 141B
0875788b7696b6b70dbfb8fff38651b073b295 141B
0875788b7696b6b70dbfb8fff38651b073b295 141B
08b182bc3f1a8184c42e5f8c17869b303804b1 369B
08b3024f7db1dc018fb1af342e69c6537e43b9 382B
09f23a67452403120faf73969ad811f799bb83 278B
0a6ff51bfc6f6adcc472f6d8c02db92ce947a8 238B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a7c76726689e65a284b4044723287b0560f5b 472B
0a8083e346ee63d4dd81831f959e54abb7a692 786B
0a8ac964a07f0f20d9cde9ef7542ff7d579e6a 1018B
0b69284002c246222953a69c5331cea1eca2eb 417B
0b70f2091d6efcdad6b4077fc35d87689d83e3 83B
0b7a900c0ae7c2ac8e58c73d6a406cab372c06 5KB
0bd1de2ea500bcea1702bc694f1653268bf026 1KB
0be833abfbd7cfe3a56cfae61f85c2207f75e9 207B
0c4466a174958430538af215aca24ba248315c 3KB
0c87a8a112ca6212e455b79dc30c8472ff0a83 351B
0c87a8a112ca6212e455b79dc30c8472ff0a83 351B
0c87a8a112ca6212e455b79dc30c8472ff0a83 351B
0c87a8a112ca6212e455b79dc30c8472ff0a83 351B
0c87a8a112ca6212e455b79dc30c8472ff0a83 351B
0c87a8a112ca6212e455b79dc30c8472ff0a83 351B
0c87a8a112ca6212e455b79dc30c8472ff0a83 351B
0c87a8a112ca6212e455b79dc30c8472ff0a83 351B
共 7694 条
- 1
- 2
- 3
- 4
- 5
- 6
- 77
资源评论
kuanglove8
- 粉丝: 0
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于flask和echarts融合交易策略的bitfinex可视化微服务.zip
- 包含了wvp-assist.tar wvp-talk.tar zlmediakit.tar .
- 3r4efgh53wgrf43tw
- 2024新版Java基础从入门到精通全套视频+资料下载
- Spring AI大模型视频教程+ChatGPT视频教程+OpenAI大模型视频教程(资料+视频教程)
- ABB工业机器人教程PDF版本
- 123321123323211
- yolov8实战第八天-pyqt5-yolov8实现车牌识别系统(论文(约7000字)+数据集+完整部署代码+代码使用说明)
- 三相桥式全桥整流电路MATALB Simulink仿真文件
- ABB机器人操作培训文档
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功