# eefe-webpack-config

> 创建基础通用的 webpack 配置

Latest version **1.1.11** (published 2021-08-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install eefe-webpack-config
pnpm add eefe-webpack-config
yarn add eefe-webpack-config
bun add eefe-webpack-config
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.11 |
| Published | 2021-08-19 |
| First published | 2021-08-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 24 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | guojiamin@sensorsdata.cn |
| Maintainers | guojiamin |
| Keywords | webpack, eefe |

## Links

- npm: https://www.npmjs.com/package/eefe-webpack-config
- npm.io page: https://npm.io/package/eefe-webpack-config

## Dependencies (24)

- [less](https://npm.io/package/less.md) ^4.1.1
- [webpack](https://npm.io/package/webpack.md) ^5.49.0
- [@babel/cli](https://npm.io/package/@babel/cli.md) ^7.14.8
- [css-loader](https://npm.io/package/css-loader.md) ^6.2.0
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.15.0
- [file-loader](https://npm.io/package/file-loader.md) ^6.2.0
- [less-loader](https://npm.io/package/less-loader.md) ^10.0.1
- [webpack-cli](https://npm.io/package/webpack-cli.md) ^4.7.2
- [babel-loader](https://npm.io/package/babel-loader.md) ^8.2.2
- [style-loader](https://npm.io/package/style-loader.md) ^3.2.1
- [node-notifier](https://npm.io/package/node-notifier.md) ^10.0.0
- [webpack-merge](https://npm.io/package/webpack-merge.md) ^5.8.0
- [postcss-loader](https://npm.io/package/postcss-loader.md) ^6.1.1
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.15.0
- [webpack-dev-server](https://npm.io/package/webpack-dev-server.md) ^3.11.2
- [@babel/preset-react](https://npm.io/package/@babel/preset-react.md) ^7.14.5
- [babel-plugin-import](https://npm.io/package/babel-plugin-import.md) ^1.13.3
- [html-webpack-plugin](https://npm.io/package/html-webpack-plugin.md) ^5.3.2
- [eslint-webpack-plugin](https://npm.io/package/eslint-webpack-plugin.md) ^3.0.1
- [mini-css-extract-plugin](https://npm.io/package/mini-css-extract-plugin.md) ^2.2.0
- [webpack-bundle-analyzer](https://npm.io/package/webpack-bundle-analyzer.md) ^4.4.2
- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) ^7.15.0
- [friendly-errors-webpack-plugin](https://npm.io/package/friendly-errors-webpack-plugin.md) ^1.7.0
- [@babel/plugin-transform-runtime](https://npm.io/package/@babel/plugin-transform-runtime.md) ^7.15.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.1.11 (latest) — 2021-08-19
- 1.1.10 — 2021-08-19
- 1.1.9 — 2021-08-19
- 1.1.8 — 2021-08-19
- 1.1.7 — 2021-08-19
- 1.1.6 — 2021-08-11
- 1.1.5 — 2021-08-11
- 1.1.4 — 2021-08-11
- 1.1.3 — 2021-08-11
- 1.1.2 — 2021-08-11
- 1.1.1 — 2021-08-11
- 1.1.0 — 2021-08-11
- 1.0.0 — 2021-08-11

## README

### 介绍

创建基础通用的 webpack 配置

### 安装

```shell
$ npm install eefe-webpack-config --save-dev
```

### 使用

- 公共配置（webpack-common-config.js 文件）

```javascript
const path = require('path');
const createWebpackConfig = require('eefe-webpack-config');

module.exports = (options) => {
  // 创建配置
  const config = createWebpackConfig(__dirname, {
    alias: {
      '@': path.join(__dirname, '../src'),
      api: path.join(__dirname, '../src/api'),
    },
    ...options,
  });
  return config;
};
```

- development 环境配置（webpack-dev-config.js 文件）

```javascript
const config = require('./webpack.common');

module.exports = config({
  proxy: {
    '/api': {
      target: 'https://api.github.com',
      changeOrigin: true,
      pathRewrite: { '^/api': '' },
    },
  },
});
```

- production 环境配置（webpack-prod-config.js 文件）

```javascript
const config = require('./webpack.common');

module.exports = config({
  isProduction: true, // 生产环境必须传
});
```

| 参数                | 值类型   | 描述               |
| :------------------ | :------- | :----------------- |
| projectAbsolutePath | `string` | 当前项目的绝对路径 |
| options             | `object` | 选项               |
| customConfig        | `object` | 自定义配置         |

---

**options 对象下的参数**
| 参数 | 值类型 | 描述 |
| :----------- | :-------- | :--------------------------------------------------------------------- |
| isProduction | `boolean` | 是否是正式环境 |
| entry | `string` | 应用入口文件路径，默认为 `./src/main.js` |
| template | `string` | 应用 HTML 文件路径 |
| alias | `object` | 编译时的别名 |
| port | `number` | devServer 端口号 |
| proxy | `object` | devServer 代理配置 |
| host | `string` | devServer 服务器监听的地址 |
| customConfig | `object` | 自定义配置（若是针对某个环境的配置需在传入时判断环境，否则为公共配置） |

> guojiamin，2021.08.19

---
_Source: https://npm.io/package/eefe-webpack-config · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
