mirror of
https://github.com/react-webpack-generators/generator-react-webpack.git
synced 2025-12-08 18:01:59 +00:00
commit 25ef9a176ee9bab902579f79415bd6047a77a62f
Author: Simon Bailey <simon@newtriks.com>
Date: Thu May 15 19:51:45 2014 +0100
Updated README
Signed-off-by: Simon Bailey <simon@newtriks.com>
commit 1b0020c8fd248bc0dc892bed1f3e315867378274
Merge: d8fd494 c468b98
Author: Edd <accounts@edd.fm>
Date: Sat Apr 26 11:13:52 2014 +0100
Merged with Master
commit d8fd494478cb7fd0d97a47a90986f4c1b29eb996
Author: Edd <accounts@edd.fm>
Date: Thu Apr 24 22:09:19 2014 +0100
Trimming redundant options from Gruntfile
commit b5015ae42b0beb770ae1b146f152b5f38764987e
Author: Edd <accounts@edd.fm>
Date: Sun Mar 30 21:32:14 2014 +0100
Moved development mode to webpack-dev-server to imrove rebuild times
commit 7d31ade8085a8d415b95c67dba69ae5157ebf9b4
Author: Edd <accounts@edd.fm>
Date: Wed Feb 26 00:18:56 2014 +0000
Changed JSX filenames to .jsx over .js
commit 00faa6182b6cb4ae46b05dd12db1e73da4b47953
Author: Edd <accounts@edd.fm>
Date: Mon Feb 24 23:39:18 2014 +0000
Updated engines & Travis build targets
commit e58e0d70639f3c3e9acc7d085b6a795365a140a6
Author: Edd <accounts@edd.fm>
Date: Mon Feb 24 23:26:04 2014 +0000
Added auto generation of a template CSS file for a component
commit f6c67351aead570224b2457261d457a1954277dc
Author: Edd <accounts@edd.fm>
Date: Mon Feb 24 00:06:42 2014 +0000
Updated default app test
commit 996d769685d1a4f20ae2c4117422790bbc347594
Author: Edd <accounts@edd.fm>
Date: Sun Feb 23 23:32:37 2014 +0000
Added test for default main component (currently identical to any other component tests)
commit 31dfcbaff6ee9aef339886897e053a339f98021b
Author: Edd <accounts@edd.fm>
Date: Sun Feb 23 22:54:04 2014 +0000
Moved webpack configuration to a separate file
- Added webpack config file
- Added Uglify to webpack config
- Added source maps in webpack config
Moved entry file back in to Gruntfile
commit 6b3a3e92b80f3121e1128e4f166cf36aa32cfa26
Author: Edd <accounts@edd.fm>
Date: Sun Feb 23 17:23:07 2014 +0000
Added distribution folder & Grunt tasks to deal with it
- Created Distribution build folder (script link broken)
- Added grunt-contrib-copy
- Added grunt-uglify
- Bumped React version number
- Switched source map types
Signed-off-by: Simon Bailey <simon@newtriks.com>
78 lines
2.5 KiB
JavaScript
78 lines
2.5 KiB
JavaScript
'use strict';
|
|
var util = require('util');
|
|
var path = require('path');
|
|
var yeoman = require('yeoman-generator');
|
|
var generalUtils = require('./util.js');
|
|
|
|
var Generator = module.exports = function Generator() {
|
|
yeoman.generators.NamedBase.apply(this, arguments);
|
|
|
|
// Add capitalize mixin
|
|
this._.mixin({ 'capitalize': generalUtils.capitalize });
|
|
this._.mixin({ 'lowercase': generalUtils.lowercase });
|
|
|
|
this.appname = path.basename(process.cwd());
|
|
|
|
this.appname = this._.slugify(this._.humanize(this.appname));
|
|
this.scriptAppName = this._.camelize(this._.capitalize(this.appname)) + generalUtils.appName(this);
|
|
this.classedName = this._.capitalize(this.name);
|
|
|
|
if (typeof this.env.options.appPath === 'undefined') {
|
|
this.env.options.appPath = this.env.options.appPath || 'src';
|
|
}
|
|
|
|
if (typeof this.env.options.testPath === 'undefined') {
|
|
this.env.options.testPath = this.env.options.testPath || 'test/spec';
|
|
}
|
|
|
|
if (typeof this.env.options.stylesPath === 'undefined') {
|
|
this.env.options.stylesPath = this.env.options.stylesPath || 'src/styles';
|
|
}
|
|
|
|
var sourceRoot = '/templates/';
|
|
this.scriptSuffix = '.js';
|
|
this.reactSuffix = '.jsx';
|
|
|
|
var stylesRoot = '/templates/styles';
|
|
this.stylesSuffix = '.css';
|
|
|
|
this.sourceRoot(path.join(__dirname, sourceRoot));
|
|
};
|
|
|
|
util.inherits(Generator, yeoman.generators.NamedBase);
|
|
|
|
Generator.prototype.appTemplate = function (src, dest) {
|
|
yeoman.generators.Base.prototype.template.apply(this, [
|
|
path.join('javascript', src + this.reactSuffix),
|
|
path.join(this.env.options.appPath, dest) + this.reactSuffix
|
|
]);
|
|
};
|
|
|
|
Generator.prototype.testTemplate = function (src, dest) {
|
|
yeoman.generators.Base.prototype.template.apply(this, [
|
|
src + this.scriptSuffix,
|
|
path.join(this.env.options.testPath, dest) + this.scriptSuffix
|
|
]);
|
|
};
|
|
|
|
Generator.prototype.stylesTemplate = function (src, dest) {
|
|
console.log(src);
|
|
yeoman.generators.Base.prototype.template.apply(this, [
|
|
src + this.stylesSuffix,
|
|
path.join(this.env.options.stylesPath, dest) + this.stylesSuffix
|
|
]);
|
|
};
|
|
|
|
Generator.prototype.htmlTemplate = function (src, dest) {
|
|
yeoman.generators.Base.prototype.template.apply(this, [
|
|
src,
|
|
path.join(this.env.options.appPath, dest.toLowerCase())
|
|
]);
|
|
};
|
|
|
|
Generator.prototype.generateSourceAndTest = function (appTemplate, testTemplate, stylesTemplate, targetDirectory) {
|
|
this.appTemplate(appTemplate, path.join('scripts', targetDirectory, this._.capitalize(this.name)));
|
|
this.testTemplate(testTemplate, path.join(targetDirectory, this._.capitalize(this.name)));
|
|
this.stylesTemplate(stylesTemplate, path.join(this._.capitalize(this.name)));
|
|
};
|