mirror of
https://github.com/wassname/generator-react-webpack.git
synced 2026-08-30 11:23:47 +08:00
generating es6 modules if --es6 flag is used
This commit is contained in:
@@ -3,12 +3,19 @@ var util = require('util');
|
||||
var ScriptBase = require('../script-base.js');
|
||||
|
||||
var ComponentGenerator = module.exports = function ComponentGenerator(args, options, config) {
|
||||
|
||||
ScriptBase.apply(this, arguments);
|
||||
};
|
||||
|
||||
util.inherits(ComponentGenerator, ScriptBase);
|
||||
|
||||
ComponentGenerator.prototype.createComponentFile = function createComponentFile() {
|
||||
this.option('es6');
|
||||
|
||||
|
||||
this.es6 = this.options.es6;
|
||||
console.log('es6:', this.es6)
|
||||
|
||||
this.generateSourceAndTest(
|
||||
'Component',
|
||||
'spec/Component',
|
||||
|
||||
@@ -19,5 +19,9 @@ var <%= classedName %> = React.createClass({
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
<% if (es6) { %>
|
||||
export default <%= classedName %>;
|
||||
<% } else { %>
|
||||
module.exports = <%= classedName %>;
|
||||
<% } %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user