mirror of
https://github.com/react-webpack-generators/generator-react-webpack.git
synced 2025-12-08 18:01:59 +00:00
generating es6 modules if --es6 flag is used
This commit is contained in:
parent
7421ef680f
commit
505d7277e9
@ -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 %>;
|
||||
<% } %>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user