Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持build参数,指定打包不同的配置文件 #36

Closed
jinzhubaofu opened this issue Mar 14, 2014 · 1 comment
Closed

支持build参数,指定打包不同的配置文件 #36

jinzhubaofu opened this issue Mar 14, 2014 · 1 comment

Comments

@jinzhubaofu
Copy link
Contributor

功能需求是这样的。往往开发、QA测试、线上环境接口配置是不一样的。每次手动切换非常麻烦而且上线时容易遗忘切换成环境。希望可以通过添加edp build的参数,打包使用不同的配置文件。例如:

// 将开发时配置文件打包
edp build --dev

// 将QA联调配置文件打包
edp build --qa

// 将生产环境配置文件打包
edp build --prod

解决方案大约是这样:
首先 假设在src下放置一个conf文件夹;其中按环境划分子文件夹

src/conf
src/conf/dev
src/conf/prod
src/conf/qa

其次 在require.config里对配置文件设定一个path;在源码中,是指定到conf/dev/config.js

require.config({
    basrUrl: 'src',
    paths: {
        conf: 'conf/dev'
    }
});

然后 在打包前,先将conf的path修改成参数指定的值,例如edp build --prod

require.config({
    basrUrl: 'xxx',
    paths: {
        conf: 'conf/prod'
    }
});

最后 正常继续其他打包工作

这样,在源码中使用require('config/some-config')不变。

@leeight
Copy link
Member

leeight commented Mar 14, 2014

我先搬家了,通过Milestone来管理issue. ecomfe/edp#171

@leeight leeight closed this as completed Mar 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants