a simple CLI for scaffolding Vue.js/React.js/微信小程序/支付宝小程序/jQuery projects.
- Node.js >= 6.4
$ npm install -g ziu
$ ziu init <project-name>
Example:
$ ziu init test
The command pulls the templates from ziu-templates, and then we list all templates in the repro.
Like this:
aliapp - 支付宝小程序模板
bdapp - 百度小程序模板
lib-pac - 基于Rollup打包组件和基础库模板
react - a react template with webpack
ttapp - 头条/抖音小程序模板
usual - 传统项目模板(use jQuery)
vue-3 - 使用vue-cli@3版本的项目模板
weapp - 微信小程序模板
then, prompts for some information, and generates the project at ./test/
.
ziu list
-
每一个模板都有4中环境,
development、testing、staging、production
-
环境变量是以
yaml
的文件格式编译,在项目根目录下的config
文件夹下有5个yaml
文件,default.yml、development.yml、testing.yml、staging.yml、production.yml
,分别对应4中环境中使用的环境变量;default.yml
是默认配置,其他环境的配置会和default.yml
中的配置合并 -
环境变量在JavaScript中获取
在yaml
中配置的环境变量都存储在process.env.ENV_DATA
中:
// 获取当前环境
// 这里并没有使用process.env.NODE_ENV作为环境区分,主要为了避免第三方库依赖process.env.NODE_ENV导致出现异常
const env = process.env.ENV_DATA.PRJ_ENV;
$ npm run dev
start a local server to development
generates tesing files
$ npm run testing
$ npm run build
generates production files