Closed hailiang-wang closed 9 years ago
http://austack-stg-server.arrking.com --> 115.28.162.221
export NODE_ENV=production # or
pm2 restart austack-server.js
how to inject configurations dynamically for production and development ? Can we have some strategy as the server ?
@lymanlai @nihgwu Since gulp build is compress the client codes into dist, then dist is published into qiniu for testing. But dist is always compressed, it is not friendly for debugging with staging service. So we should create another issue to enable gulp build
with non-compress, maybe gulp build:raw.
Basically, the client's configurations or constants should be injected in this way: (1) first, there should be two config file, something like development.json and production.json (2) then, use gulp serve, development.json is used as config or constants. (3) when use gulp build, production.json is used for config or constants.
@lymanlai @nihgwu All HTTP Request with $resource or $http should use api url in Config
module. Even it is in development and use proxy. Since then, we can connect client and server for production usage.
http://www.austack.com/ for index page http://manager.austack.com/ for admin(dave) to use http://api.austack.com/ for api server
but we need http://preview.www.austack.com/ for our production online test, this will use nginx and host for the dist folder on our own sever, after we confirm everything is all right, then use the qiniu tool to sync online
actully, we do not need proxy in the gulp then. cause our production will be cross domain.
cd ~/git/austack
NODE_ENV=production npm start
find this gulp plugin: https://www.npmjs.com/package/gulp-angular-constant/
@nihgwu I think we can use this gulp plugin for configuration for client instead of writing something alike.
env=production gulp build
for default the gulp task will take it as development env
./gulp/config.js
module.exports = function (options) {
gulp.task('config', function () {
var env = options.env || 'development';
gulp.src(options.src + '/app/config/env-' + env + '.json')
.pipe($.ngConstant({
name: 'austackApp.config',
templatePath: options.src + '/app/config/config.tpl.ejs',
deps: []
}))
.pipe($.rename(options.src + '/app/config.js'))
.pipe(gulp.dest(''));
});
};
Description
Solution
build
env=production gulp build
development
for default the gulp task will take it as development env
./gulp/config.js