mirror of
https://github.com/wassname/generator-react-webpack.git
synced 2026-10-06 13:00:29 +08:00
Basic project generator setup
TODO: - App tests - Generator tests - Component generator Signed-off-by: Simon Bailey <simon@newtriks.com>
This commit is contained in:
commit
b1562cd74c
29 files changed
+17271
No files matched your search
@@ -0,0 +1,137 @@
|
||||
'use strict';
|
||||
var LIVERELOAD_PORT = 35729;
|
||||
var lrSnippet = require('connect-livereload')({
|
||||
port: LIVERELOAD_PORT
|
||||
});
|
||||
var mountFolder = function (connect, dir) {
|
||||
return connect.static(require('path').resolve(dir));
|
||||
};
|
||||
|
||||
module.exports = function (grunt) {
|
||||
// Let *load-grunt-tasks* require everything
|
||||
require('load-grunt-tasks')(grunt);
|
||||
// Read configuration from package.json
|
||||
var pkgConfig = grunt.file.readJSON('package.json');
|
||||
var jshintConfig = grunt.file.readJSON('.jshintrc');
|
||||
|
||||
var loaders = [{
|
||||
test: /\.css$/,
|
||||
loader: 'style!css'
|
||||
}, {
|
||||
test: /\.gif/,
|
||||
loader: 'url-loader?limit=10000&minetype=image/gif'
|
||||
}, {
|
||||
test: /\.jpg/,
|
||||
loader: 'url-loader?limit=10000&minetype=image/jpg'
|
||||
}, {
|
||||
test: /\.png/,
|
||||
loader: 'url-loader?limit=10000&minetype=image/png'
|
||||
}, {
|
||||
test: /\.js$/,
|
||||
loader: 'jsx-loader'
|
||||
}];
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: pkgConfig,
|
||||
webpack: {
|
||||
development: {
|
||||
entry: './<%= pkg.src %>/scripts/components/<%= pkg.mainInput %>.js',
|
||||
output: {
|
||||
path: '<%= pkg.src %>/scripts/',
|
||||
filename: '<%= pkg.mainOutput %>.js'
|
||||
},
|
||||
debug: true,
|
||||
cache: true,
|
||||
stats: {
|
||||
colors: true,
|
||||
reasons: true
|
||||
},
|
||||
jshint: grunt.util._.merge(jshintConfig, {
|
||||
emitErrors: false,
|
||||
failOnHint: false
|
||||
}),
|
||||
module: {
|
||||
preLoaders: [{
|
||||
test: '\\.js$',
|
||||
exclude: 'node_modules',
|
||||
loader: 'jshint'
|
||||
}],
|
||||
loaders: loaders
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
webpack: {
|
||||
files: ['<%= pkg.src %>/scripts/{,*/}*.js',
|
||||
'<%= pkg.src %>/styles/{,*/}*.css',
|
||||
'!<%= pkg.src %>/scripts/<%= pkg.mainOutput %>.js'
|
||||
],
|
||||
tasks: ['webpack:development']
|
||||
},
|
||||
livereload: {
|
||||
options: {
|
||||
livereload: LIVERELOAD_PORT
|
||||
},
|
||||
files: [
|
||||
'<%= pkg.src %>/{,*/}*.html',
|
||||
'<%= pkg.src %>/scripts/<%= pkg.mainOutput %>.js'
|
||||
]
|
||||
}
|
||||
},
|
||||
connect: {
|
||||
options: {
|
||||
port: 8000,
|
||||
// Change this to '0.0.0.0' to access the server from outside.
|
||||
hostname: 'localhost'
|
||||
},
|
||||
livereload: {
|
||||
options: {
|
||||
middleware: function (connect) {
|
||||
return [
|
||||
lrSnippet,
|
||||
mountFolder(connect, pkgConfig.src)
|
||||
];
|
||||
}
|
||||
}
|
||||
},
|
||||
dist: {
|
||||
options: {
|
||||
middleware: function (connect) {
|
||||
return [
|
||||
mountFolder(connect, pkgConfig.dist)
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
open: {
|
||||
server: {
|
||||
url: 'http://localhost:<%= connect.options.port %>'
|
||||
}
|
||||
},
|
||||
karma: {
|
||||
unit: {
|
||||
configFile: 'karma.conf.js'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('server', function (target) {
|
||||
if (target === 'dist') {
|
||||
return grunt.task.run(['build', 'open', 'connect:dist:keepalive']);
|
||||
}
|
||||
|
||||
grunt.task.run([
|
||||
'connect:livereload',
|
||||
'webpack:development',
|
||||
'open',
|
||||
'watch'
|
||||
]);
|
||||
});
|
||||
|
||||
grunt.registerTask('test', ['karma']);
|
||||
|
||||
grunt.registerTask('build', []);
|
||||
|
||||
grunt.registerTask('default', []);
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "<%= _.slugify(appname) %>",
|
||||
"version": "0.0.0",
|
||||
"src": "src",
|
||||
"test": "test",
|
||||
"dist": "dist",
|
||||
"mainInput": "<%= scriptAppName %>",
|
||||
"mainOutput": "main",
|
||||
"dependencies": {
|
||||
"react": "~0.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "~0.4.2",
|
||||
"load-grunt-tasks": "~0.2.1",
|
||||
"grunt-contrib-watch": "~0.5.3",
|
||||
"grunt-contrib-connect": "~0.6.0",
|
||||
"connect-livereload": "~0.3.1",
|
||||
"webpack": "~1.0.0-beta4",
|
||||
"jsx-loader": "petehunt/jsx-loader",
|
||||
"grunt-webpack": "~1.0.0",
|
||||
"style-loader": "~0.6.0",
|
||||
"url-loader": "~0.5.2",
|
||||
"css-loader": "~0.6.6",
|
||||
"karma-script-launcher": "~0.1.0",
|
||||
"karma-chrome-launcher": "~0.1.2",
|
||||
"karma-firefox-launcher": "~0.1.3",
|
||||
"karma-jasmine": "~0.1.5",
|
||||
"karma-phantomjs-launcher": "~0.1.1",
|
||||
"karma": "~0.10.9",
|
||||
"grunt-karma": "~0.6.2",
|
||||
"karma-webpack-plugin": "~1.0.0",
|
||||
"webpack-dev-server": "~1.0.2",
|
||||
"grunt-open": "~0.2.2",
|
||||
"jshint-loader": "~0.6.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
### SublimeText ###
|
||||
*.sublime-workspace
|
||||
|
||||
### OSX ###
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
### Windows ###
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# App specific
|
||||
|
||||
node_modules/
|
||||
.tmp
|
||||
/src/scripts/main.js
|
||||
@@ -0,0 +1,19 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<title></title>
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
</head>
|
||||
<body>
|
||||
<!--[if lt IE 8]>
|
||||
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
|
||||
<![endif]-->
|
||||
<div id="content">
|
||||
<h1>If you can see this, something is broken (or JS is not enabled).</h1>
|
||||
</div>
|
||||
<script type="text/javascript" src="scripts/main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,13 @@
|
||||
# http://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"node": true,
|
||||
"browser": true,
|
||||
"esnext": true,
|
||||
"bitwise": true,
|
||||
"camelcase": false,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"indent": 2,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"quotmark": "single",
|
||||
"regexp": true,
|
||||
"undef": true,
|
||||
"unused": false,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"smarttabs": true,
|
||||
"white": true,
|
||||
"newcap": false,
|
||||
"globals": {
|
||||
"React": true
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"node": true,
|
||||
"browser": true,
|
||||
"esnext": true,
|
||||
"bitwise": true,
|
||||
"camelcase": false,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"indent": 2,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"quotmark": "single",
|
||||
"regexp": true,
|
||||
"undef": true,
|
||||
"unused": false,
|
||||
"strict": true,
|
||||
"trailing": true,
|
||||
"smarttabs": true,
|
||||
"white": true,
|
||||
"newcap": false,
|
||||
"globals": {
|
||||
"after": false,
|
||||
"afterEach": false,
|
||||
"react": false,
|
||||
"before": false,
|
||||
"beforeEach": false,
|
||||
"browser": false,
|
||||
"describe": false,
|
||||
"expect": false,
|
||||
"inject": false,
|
||||
"it": false,
|
||||
"spyOn": false,
|
||||
"jasmine": false,
|
||||
"spyOnConstructor": false,
|
||||
"React": true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
(function() {
|
||||
|
||||
var Ap = Array.prototype;
|
||||
var slice = Ap.slice;
|
||||
var Fp = Function.prototype;
|
||||
|
||||
if (!Fp.bind) {
|
||||
// PhantomJS doesn't support Function.prototype.bind natively, so
|
||||
// polyfill it whenever this module is required.
|
||||
Fp.bind = function(context) {
|
||||
var func = this;
|
||||
var args = slice.call(arguments, 1);
|
||||
|
||||
function bound() {
|
||||
var invokedAsConstructor = func.prototype && (this instanceof func);
|
||||
return func.apply(
|
||||
// Ignore the context parameter when invoking the bound function
|
||||
// as a constructor. Note that this includes not only constructor
|
||||
// invocations using the new keyword but also calls to base class
|
||||
// constructors such as BaseClass.call(this, ...) or super(...).
|
||||
!invokedAsConstructor && context || this,
|
||||
args.concat(slice.call(arguments))
|
||||
);
|
||||
}
|
||||
|
||||
// The bound function must share the .prototype of the unbound
|
||||
// function so that any object created by one constructor will count
|
||||
// as an instance of both constructors.
|
||||
bound.prototype = func.prototype;
|
||||
|
||||
return bound;
|
||||
};
|
||||
}
|
||||
})();
|
||||
+16336
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user