# craco-profile

> 基于craco的配置插件

Latest version **1.0.2** (published 2020-05-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install craco-profile
pnpm add craco-profile
yarn add craco-profile
bun add craco-profile
```

## 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.0.2 |
| Published | 2020-05-28 |
| First published | 2020-05-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | 张添 |
| Maintainers | villaincoder |

## Links

- npm: https://www.npmjs.com/package/craco-profile
- Repository: git@github.com:villaincoder/craco-profile
- npm.io page: https://npm.io/package/craco-profile

## Recent versions

- 1.0.2 (latest) — 2020-05-28
- 1.0.1 — 2020-05-28
- 1.0.0 — 2020-05-28

## README

# craco-profile
基于craco的配置插件

## 使用
1. 安装依赖<br/>`yarn add craco-profile`<br/>或<br/>`npm i craco-profile`
2. 修改craco.confign.js文件，参考如下
    ```
    const CracoProfile = require('craco-profile');
   
    CracoProfile.setup();
    
    module.exports = {
      plugins: [
        {
          plugin: CracoProfile,
        },
        // ... other plugins
      ]
    };
    ```
3. 在项目根目录建立profile.js文件，参考如下
    ```
    module.exports = {
     DEV: {
       PUBLIC_URL: '',
       SERVER_URL: 'http://localhost:8080/api'
     },
     QA: {
       PUBLIC_URL: '/myproject',
       SERVER_URL: 'http://xxx.com/api'
     },
     PROD: {
       PUBLIC_URL: '/myproject',
       SERVER_URL: 'http://yyy.com/api'
     },
    };
    ```
5. 在前端js代码中可以使用`process.env.PROFILE.SERVER_URL`来访问
6. 编译时使用`yarn build --profile=QA`来指定配置名称
7. 开发时可以在项目根目录建立profile.local.js文件，格式与profile.js文件一致。profile.local.js会覆盖profile.js中的属性。注意：profile.local.js最好加到.gitignore中，这样多人协同开发可以自由控制自己想要的配置参数。

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