Code Monkey home page Code Monkey logo

redfish's Introduction

如何编译不同环境的小程序包

  • 添加自定义环境域名配置JSON文件
文件 说明
config.xytest.json xytest 环境
config.test.json 甲方 测试环境
config.star.json 星云 star 环境
.... 更多自定义环境
  • package.json 中添加自定义条件编译配置
"uni-app": {
		"scripts": {
			"xytest": {
				"title": "星云TEST", // 在HBuilderX中会显示在 运行/发行 菜单中
				"env": {
					"UNI_PLATFORM": "mp-weixin" // 编译基准平台,详见uni-app官网
				},
				"define": {
					"XYTEST": true // 自定义条件编译常量
				}
			},
			"first-party-test": {
				"title": "TEST",
				"env": {
					"UNI_PLATFORM": "mp-weixin"
				},
				"define": {
					"FIRST-PARTY-TEST": true
				}
			}
		}
	}
  • main.js 使用条件编译导入添加的自定义环境域名JSON文件
// #ifdef XYTEST
const {
	domain,
	imgDomain,
	businessDomain
} = require('./config.xytest.json')
// #endif
  • api/http.js 添加
// #ifdef XYTEST
	let h = require('../config.xytest.json')
// #endif
  • HBuilderX 会根据 package.json 的扩展配置,在 运行 / 发行 菜单下生成自定义菜单,点击相应菜单进行编译即可,如图所示:

Snipaste_2020-09-30_15-27-27

Snipaste_2020-09-30_15-27-42

redfish's People

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.