0.1.5 • Published 3 years ago

feflow-devkit-xbc-webpack4 v0.1.5

Weekly downloads
1
License
ISC
Repository
github
Last release
3 years ago

特性

  • 使用webpack4 + babel7 最新的构建解决方案

  • 支持React,Vue的编译运行

  • 目前支持多个环境配置(dev, test,formalTest,demo, prod )

开始使用

先通过 cnpm 安装 feflow 开始.

cnpm install @feflow/cli -g

添加feflow配置文件

在项目根目录添加 feflow.json 或者 feflow.js 配置文件

{
    "devkit": {
        "commands": {
            "dev": {
                "builder": "feflow-devkit-xbc-webpack4:dev",
                "options": { // 配置单独配置 配置项参考下面公用配置项
                    "isMinicss": false,
                    "port": 8013
                }
            },
            "test": {
                "builder": "feflow-devkit-xbc-webpack4:test",
                "options": {
                    "isMinicss": true
                }
            },
            "formalTest": {
                "builder": "feflow-devkit-xbc-webpack4:formalTest",
                "options": {
                    "isMinicss": true
                }
            },
            "demo": {
                "builder": "feflow-devkit-xbc-webpack4:demo",
                "options": {
                    "isMinicss": true
                }
            },
            "build": {
                "builder": "feflow-devkit-xbc-webpack4:build",
                "options": {
                    "port": 8003,
                    "isMinicss": true,
                    externals: [{
                        optionsId: 100, // xbc会将 optionsId 一致的配置去重,用作公共配置和单个配置的 去重
                        module: "antd",
                        entry: "https://cdn.bootcss.com/antd/3.26.12/antd.min.js",
                        global: "antd"
                    }, {
                        module: "Vue",
                        entry: "",
                        global: "vue"
                    }, ],
                }
            }
        },
        "commons": { // 此处为公用配置
            "entry": "main.js", // 配置项目webpack 编译入口
            "isModule": false, // 开启css模块化 (vue项目不需要开启)
            "isMinicss": true, // 是否需要抽离css (本地调试环境不需要)		
            "hasAnalyzer": false, // 是否开启webpack包大小的调试
            "analyzerOptions": { // 调试包的配置
                "analyzerPort": 3478
            },
            "port": 1234, // webpack静态服务器启动端口号
            "alias": { // webpack别名配置
                "@": "src",
            },
            externals: [{
                optionsId: 100, //  xbc会将 optionsId 一致的配置去重,用作公共配置和单个配置的 去重
                module: "antd",
                entry: "https://cdn.bootcss.com/antd/3.26.12/antd.min.js",
                global: "antd"
            }, {
                module: "Vue",
                entry: "",
                global: "vue"
            }, ],
            "envs": { // 环境变量配置 目前只支持固定环境变量配置
                "dev": {
                    "envObj": {
                        "NODE_ENV": "\"development\"",
                        "API_HOST": "\"http://xxx.xxx.xx.x:xxxx\"",
                    }
                },
                "test": {
                    "envObj": {
                        "NODE_ENV": "\"test\"",
                        "API_HOST": "\"http://xxx.xxx.xx.x:xxxx\"",
                    }
                },
                "formalTest": {
                    "envObj": {
                        "NODE_ENV": "\"formalTest\"",
                        "API_HOST": "\"http://xxx.xxx.xx.x:xxxx\"",
                    }
                },
                "demo": {
                    "envObj": {
                        "NODE_ENV": "\"demo\"",
                        "API_HOST": "\"http://xxx.xxx.xx.x:xxxx\"",
                    }
                },
                "build": {
                    "envObj": {
                        "NODE_ENV": "\"production\"",
                        "API_HOST": "\"http://xxx.xxx.xx.x:xxxx\"",
                    }
                }
            }
        }
    }
}
   

API

参数说明必须类型默认值
commands脚本配置命令trueobject{}
commons面包屑路径trueobject{}

commands

参数说明必须类型默认值
dev,test...对应不同的环境trueobject{}
builder对应不同的脚本trueobject{}
options项目具体配置对应commons中参数trueobject{}

commons

参数说明必须类型默认值
entrywebpack编译入口,例子index.tsxtruestring
isModule开启css模块化 (vue项目不需要开启)trueobject{}
isMinicss是否需要抽离css (本地调试环境不需要)trueobject{}
hasAnalyzer是否开启webpack包大小的调试trueobject{}
analyzeranalyzer调试包的配置trueobject{}
portwebpack静态服务器启动端口号truenumber
aliaswebpack别名配置trueobject{}
externalsexternals配置truearray[]
envs环境变量配置 目前只支持固定环境变量配置trueobject{}

配置说明

  • 项目中需要用到的技术栈和UI框架建议使用externals插件配置
  • Vue项目
    	- 配置isModule为false
  • React项目 - 配置isModule为true

模板

模板使用方式
	fef install generator-**
	fef init 
搭配套件使用的模板
自定义模板

*配置注意事项

  • 单个环境的配置比commons中的配置优先级高

  • 类似externals这种对象数组的配置在commons和单个环境中同时存在时,插件会将optionsId相同的配置去重

  • 目前只支持固定环境变量配置

配置文件demo

Vue项目配置

React项目配置

命令

根据作者目前公司配置的环境 可以只使用其中一部分

$ fef dev      # 本地开发时的命令
$ fef test     # 发布时的打包命令开发测试
$ fef formalTest   # 发布时的打包命令测试测试
$ fef demo     # 发布时的打包命令演示环境
$ fef build    # 发布时的打包命令生产环境

本地调试

点击进入

发布

  1. 发布版本
	npm run release
  1. 生成CHANGELOG
	npm run changelog

发布日志

本项目遵从 Semantic Versioning. 每次发布信息都会在 Github 的 Releases 中呈现.

贡献代码方式

pr工作流

git提交规范

参考地址

eslint规范

待定

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

4 years ago

0.0.44

4 years ago

0.1.0

4 years ago

0.0.40

4 years ago

0.0.41

4 years ago

0.0.38

4 years ago

0.0.37

4 years ago

0.0.36

4 years ago

0.0.35

4 years ago

0.0.34

4 years ago

0.0.32

4 years ago

0.0.33

4 years ago

0.0.31

4 years ago

0.0.30

4 years ago

0.0.29

4 years ago

0.0.28

4 years ago

0.0.27

4 years ago

0.0.26

4 years ago

0.0.25

4 years ago

0.0.24

4 years ago

0.0.22

4 years ago

0.0.23

4 years ago

0.0.20

4 years ago

0.0.21

4 years ago

0.0.19

4 years ago

0.0.17

4 years ago

0.0.16

4 years ago

0.0.15

4 years ago

0.0.14

4 years ago

0.0.13

4 years ago

0.0.11

4 years ago

0.0.12

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago