mirror of
https://github.com/wassname/generator-react-webpack.git
synced 2026-09-11 12:10:36 +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 ScriptBase = require('../script-base.js');
|
||||||
|
|
||||||
var ComponentGenerator = module.exports = function ComponentGenerator(args, options, config) {
|
var ComponentGenerator = module.exports = function ComponentGenerator(args, options, config) {
|
||||||
|
|
||||||
ScriptBase.apply(this, arguments);
|
ScriptBase.apply(this, arguments);
|
||||||
};
|
};
|
||||||
|
|
||||||
util.inherits(ComponentGenerator, ScriptBase);
|
util.inherits(ComponentGenerator, ScriptBase);
|
||||||
|
|
||||||
ComponentGenerator.prototype.createComponentFile = function createComponentFile() {
|
ComponentGenerator.prototype.createComponentFile = function createComponentFile() {
|
||||||
|
this.option('es6');
|
||||||
|
|
||||||
|
|
||||||
|
this.es6 = this.options.es6;
|
||||||
|
console.log('es6:', this.es6)
|
||||||
|
|
||||||
this.generateSourceAndTest(
|
this.generateSourceAndTest(
|
||||||
'Component',
|
'Component',
|
||||||
'spec/Component',
|
'spec/Component',
|
||||||
|
|||||||
@@ -19,5 +19,9 @@ var <%= classedName %> = React.createClass({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
<% if (es6) { %>
|
||||||
|
export default <%= classedName %>;
|
||||||
|
<% } else { %>
|
||||||
module.exports = <%= classedName %>;
|
module.exports = <%= classedName %>;
|
||||||
|
<% } %>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user