Skip to content

Commit

Permalink
[fix] comment out support for define via client, add JSON.stringify v…
Browse files Browse the repository at this point in the history
…alue of pkg.spm.define.key is an object
  • Loading branch information
jaredleechn committed Nov 5, 2015
1 parent ff00da4 commit a2aba77
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,20 @@ function getWebpackOpts(opts, callback) {

defineContent = opts.build.pkg.spm.define && opts.build.pkg.spm.define[defineMode];

}else if(defineMode.substr(0, 1) === '{' && defineMode.substr(-1) === '}' && false){
}

// support for define via client temporarily, format: --define '{NAME:"name",AGE:11,FLAG:true,STRINGFLAG:"true"}'
// remeber add json5 into pkg.dependencies

/*else if(defineMode.substr(0, 1) === '{' && defineMode.substr(-1) === '}'){
defineContent = require('json5').parse(defineMode);
}
}*/

if(typeof(defineContent) === 'object'){
for(var i in defineContent){
typeof(defineContent[i]) === 'string' && (defineContent[i] = JSON.stringify(defineContent[i]));
(typeof(defineContent[i]) === 'string' || typeof(defineContent[i] === 'object')) && (defineContent[i] = JSON.stringify(defineContent[i]));
}
args.plugins.push(new webpack.DefinePlugin(defineContent));
}
Expand Down

0 comments on commit a2aba77

Please sign in to comment.