open-index/open-npm huggingface dataset:
npm package: @newstudios/koa2-middleware-ua
Description: A middleware that set ua object for every incoming HTTP request in Koa2.
Author: chengyu@xinpianchang.com
Latest version: 2.0.0

<div align="center">
  <h1>koa2-middleware-ua</h1>
</div>

<p align="center">
  A middleware that generates ua object for every incoming HTTP request in Koa2.
</p>

## How to develop

Using `VSCode` as deafult for *debugger*

```
# Using NPM
npm run example

# Using Yarn
yarn example
```

## How to use
### Installation

```
# Using NPM
$ npm install --save @xpc/koa2-middleware-ua

# Using Yarn
$ yarn add @xpc/koa2-middleware-ua
```



## Usage

Use `@xpc/koa2-middleware-ua` as a middleware for a [koa](https://github.com/koajs/koa) app. By default, it generates a unique uuid (v4) and exposes it on the response via the `X-Request-ID` header. The id is also saved as part of the *ctx.req.id*、*ctx.request.id*、*ctx.id*.

In the following example, the generated uuid is manually exposed on the body for debugging purposes:

```js
const Koa = require('koa');
const { userAgent } = require('@xpc/koa2-middleware-ua');
const app = new Koa();

app.use(userAgent);
app.use(async ctx => {
  ctx.body = ctx.ua;
});

app.listen(3000);
```

打开浏览器访问 http://localhost:3000

```bash
{"_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36"}
```


## API

### ctx.ua 对象包含

```node
{
  _agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Safari/537.36"
  isIOS: false
  isMobile: false
  isVmovierApp: false
  isWeixin: false
  isXpcApp: false
  xpcAppVersion: null
}
```

## License

Provided under the terms of the MIT License

Copyright © 2020, [xinpianchang](https://www.xinpianchang.com).
npm package: @newstudios/next-less-loader
Description: changed version for next-less
Author: chengyu@xinpianchang.com
Latest version: 1.0.0

# next-less-loader

基于业务完善版本的 less loader for nextjs

## 差异

对比官方提供的 [next-less](https://github.com/vercel/next-plugins/blob/master/packages/next-less/index.js)，多了从 `next.config.js` 中读取了一个配置项 `cssModulesExclude`(数组类型)


## 配置方式

在 `next.config.js` 中的配置信息如下：

```
cssModulesExclude: [
  /node_modules/,
  /assets/
]
```

如果配置了（只要 cssModulesExclude 对应的数组值长度大于 0），`next-less-loader` 内部会关闭指定规则的 cssModules（设置 `false`）

内部代码设计：

```
const globlaCssWithoutCssModuleLoader = cssLoaderConfig(config, {
  cssModules: false,
  ...
})

const globalLessWithoutCssModuleLoader = cssLoaderConfig(config, {
  cssModules: false,
  ...
})


config.module.rules.push({
  test: /\.less$/,
  include: cssModulesExclude,
  use: globalLessWithoutCssModuleLoader,
})
```

其他配置项：

* cssModules
* cssLoaderOptions
* postcssLoaderOptions
* lessLoaderOptions


## 依赖

* [@zeit/next-css](https://github.com/vercel/next-plugins/blob/master/packages/next-css/index.js)
* [webpack-filter-warnings-plugin](https://github.com/mattlewis92/webpack-filter-warnings-plugin#readme)