tuntuntutu的本地服务和打包配置
如果项目通过tuntuntutu
创建,则不需要单独安装。
yarn add tuntuntutu-scabbard -D
// or
npm install tuntuntutu-scabbard --save-dev
serve
开启本地服务tuntuntutu-scabbard serve
参数 | 默认值 | 说明 | 示例 |
---|---|---|---|
--https | false | 使用https | tuntuntutu-scabbard serve --https |
--host | 本机ip | 修改host | tuntuntutu-scabbard serve --host 127.0.0.1 |
--port | 8088 | 修改端口 | tuntuntutu-scabbard serve --port 8888 |
--open | false | 自动打开浏览器 | tuntuntutu-scabbard serve --open |
--env | development | 修改全局变量ENV的值 | tuntuntutu-scabbard serve --env stable |
build
打包编译 tuntuntutu-scabbard build
参数 | 默认值 | 说明 | 示例 |
---|---|---|---|
-R, --no-root | false | 是否设置publicPath | tuntuntutu-scabbard build -R |
-n, --project-name | tuntuntutu.config.js中的name | publicPath的值 | tuntuntutu-scabbard build -n my-app |
--cdn | 无 | 设置cdn地址 | tuntuntutu-scabbard build --cdn https://cdn.xxxx.cn |
--env | production | 修改全局变量ENV的值 | tuntuntutu-scabbard build --env stable |
tuntuntutu-scabbard
的功能依赖于tuntuntutu.config.js
// tuntuntutu.config.js
module.exports = {
// 项目名称,执行 tuntuntutu-scabbard build -R 时的 publicPath 的默认值
name: 'my-app',
// 终端类型(pc|mobile)
platform: 'pc',
// 项目类型(mpa|spa|lite)
type: 'spa',
// 自定义antd的主题
// 参考地址: https://ant.design/docs/react/customize-theme-cn
theme: {
'primary-color': '#14161a',
},
// webpack-dev-server的proxy
// 详细配置可参考https://webpack.js.org/configuration/dev-server/#devserver-proxy
proxy: {
'/api': 'http://localhost:3000'
},
};