Feature/webpack #2

Merged
merged 7 commits into from Nov 28, 2015
+247 −181
Split
View
@@ -70,3 +70,7 @@ Icon?
Thumbs.db
packages
build
+dist
+
+# Webpack
+src/bundle.js
View
@@ -0,0 +1,6 @@
+{
+ "compilerOptions": {
+ "target": "ES6",
+ "module": "commonjs"
+ }
+}
View
@@ -2,7 +2,14 @@
"name": "angular-blackjack",
"version": "0.0.1",
"devDependencies": {
+ "babel": "^6.1.18",
+ "babel-core": "^6.2.1",
+ "babel-loader": "^6.2.0",
+ "babel-plugin-transform-es2015-modules-commonjs": "^6.2.0",
+ "babel-preset-es2015": "^6.1.18",
+ "css-loader": "^0.23.0",
"del": "^1.1.1",
+ "file-loader": "^0.8.5",
"gulp": "^3.8.11",
"gulp-concat": "^2.5.0",
"gulp-gh-pages": "^0.5.0",
@@ -12,6 +19,23 @@
"karma": "^0.12.31",
"karma-jasmine": "^0.3.5",
"karma-phantomjs-launcher": "^0.1.4",
- "main-bower-files": "^2.5.0"
+ "main-bower-files": "^2.5.0",
+ "ng-annotate-loader": "0.0.10",
+ "raw-loader": "^0.5.1",
+ "style-loader": "^0.13.0",
+ "url-loader": "^0.5.7",
+ "webpack": "^1.12.9",
+ "webpack-dev-server": "^1.14.0"
+ },
+ "dependencies": {
+ "angular": "^1.4.8",
+ "angular-hotkeys": "^1.6.0",
+ "bootstrap": "^3.3.6",
+ "jquery": "^2.1.4",
+ "mousetrap": "^1.5.3"
+ },
+ "scripts": {
+ "start": "node_modules/.bin/webpack-dev-server --content-base src",
+ "build": "NODE_ENV=production node node_modules/.bin/webpack && cp src/index.html dist/index.html"
}
}
@@ -1,14 +1,7 @@
-(function () {
- 'use strict';
-
- angular
- .module('blackjack.card')
- .directive('blackjackCard', BlackjackCard)
- .controller('BlackjackCardController', BlackjackCardController);
+import BlackjackCardController from './card';
BlackjackCard.$inject = ['$window'];
- BlackjackCardController.$inject = ['$scope'];
/* @ngInject */
function BlackjackCard($window)
{
@@ -26,58 +19,12 @@
card: '=',
cardIndex: '@'
},
- controller: 'BlackjackCardController',
+ controller: BlackjackCardController,
controllerAs: 'vm',
bindToController: true
};
return directive;
}
- /* @ngInject */
- function BlackjackCardController($scope){
- var vm = this;
-
- vm.rank;
- vm.suit;
-
- vm.init = function(){
- vm.displayCard();
-
- $scope.$watchCollection('vm.card',function(newC,oldC){
- vm.displayCard();
- });
- };
-
- vm.displayCard = function(){
- if(vm.hideValue){
- vm.suit = 'back';
- vm.rank = '';
- }
- else {
- vm.rank = vm.card.rank;
- var cardSuit;
- switch (vm.card.suit) {
- //'C', 'D', 'S', 'H'
- case 'C':
- cardSuit = 'suitclubs';
- break;
- case 'D':
- cardSuit = 'suitdiamonds';
- break;
- case 'H':
- cardSuit = 'suithearts';
- break;
- case 'S':
- cardSuit = 'suitspades';
- break;
- }
- vm.suit = cardSuit;
- }
-
- vm.cardIndexClass = 'card-index-' + vm.cardIndex;
- };
-
- vm.init();
- }
-})();
+export default BlackjackCard;
@@ -1,10 +1,3 @@
-(function () {
- 'use strict';
-
- angular
- .module('blackjack.card')
- .directive('blackjackHand', BlackjackHand);
-
/* @ngInject */
function BlackjackHand()
{
@@ -24,4 +17,5 @@
return directive;
}
-})();
+
+export default BlackjackHand;
View
@@ -0,0 +1,50 @@
+BlackjackCardController.$inject = ['$scope'];
+
+/* @ngInject */
+function BlackjackCardController($scope){
+ var vm = this;
+
+ vm.rank;
+ vm.suit;
+
+ vm.init = function(){
+ vm.displayCard();
+
+ $scope.$watchCollection('vm.card',function(newC,oldC){
+ vm.displayCard();
+ });
+ };
+
+ vm.displayCard = function(){
+ if(vm.hideValue){
+ vm.suit = 'back';
+ vm.rank = '';
+ }
+ else {
+ vm.rank = vm.card.rank;
+ var cardSuit;
+ switch (vm.card.suit) {
+ //'C', 'D', 'S', 'H'
+ case 'C':
+ cardSuit = 'suitclubs';
+ break;
+ case 'D':
+ cardSuit = 'suitdiamonds';
+ break;
+ case 'H':
+ cardSuit = 'suithearts';
+ break;
+ case 'S':
+ cardSuit = 'suitspades';
+ break;
+ }
+ vm.suit = cardSuit;
+ }
+
+ vm.cardIndexClass = 'card-index-' + vm.cardIndex;
+ };
+
+ vm.init();
+}
+
+export default BlackjackCardController;
@@ -1,6 +0,0 @@
-(function () {
- 'use strict';
-
- angular
- .module('blackjack.card', []);
-})();
@@ -1,11 +1,3 @@
-(function () {
- 'use strict';
-
- angular
- .module('blackjack.card')
- .factory('CardService', CardService);
-
-
function CardService(){
var service = {
newDeck: newDeck,
@@ -92,4 +84,4 @@
}
-})();
+export default CardService;
View
@@ -0,0 +1,13 @@
+import angular from 'angular';
+import BlackjackCard from './card.directive';
+import CardService from './card.service';
+import BlackjackHand from './card.hand.directive';
+
+let cardModule = angular.module('blackjack.card', []);
+
+cardModule
+ .directive('blackjackCard', BlackjackCard)
+ .factory('CardService', CardService)
+ .directive('blackjackHand', BlackjackHand);
+
+export default cardModule;
@@ -1,6 +0,0 @@
-(function () {
- 'use strict';
-
- angular
- .module('blackjack.dealer', []);
-})();
@@ -1,10 +1,3 @@
-(function () {
- 'use strict';
-
- angular
- .module('blackjack.dealer')
- .factory('DealerService', DealerService);
-
DealerService.$inject =['$timeout','GameService'];
function DealerService($timeout, GameService){
@@ -119,9 +112,6 @@
return service;
////////////////
-
-
-
}
-})();
+export default DealerService;
@@ -0,0 +1,9 @@
+import angular from 'angular';
+import DealerService from './dealer.service';
+
+let dealerModule = angular.module('blackjack.dealer', []);
+
+dealerModule
+ .factory('DealerService', DealerService);
+
+export default dealerModule;
@@ -1,10 +1,3 @@
-(function(){
- 'use strict';
-
- angular
- .module('blackjack.game')
- .controller('GameController',GameController);
-
GameController.$inject = ['$timeout','PlayerService', 'CardService', 'GameService', 'DealerService', 'hotkeys'];
function GameController($timeout, PlayerService, CardService, GameService, DealerService, hotkeys){
@@ -237,4 +230,6 @@
game.init();
}
-})();
+
+export default GameController;
+
@@ -1,16 +1,14 @@
-(function(){
- 'use strict';
+import GameController from './game.controller';
+import template from './game.directive.html';
- angular
- .module('blackjack.game')
- .directive('blackjackGame', blackjackGame);
-
- function blackjackGame(){
+let GameDirective =
+ function (){
return {
restrict: 'E',
- templateUrl: 'app/game/game.directive.html',
- controller: 'GameController',
+ template: template,
+ controller: GameController,
controllerAs: 'game'
}
- }
-})();
+ };
+
+export default GameDirective;
@@ -1,6 +0,0 @@
-(function() {
- 'use strict';
-
- angular.module('blackjack.game', []);
-
-})();
@@ -1,10 +1,3 @@
-(function(){
- 'use strict';
-
- angular
- .module('blackjack.game')
- .factory('GameService', GameService);
-
function GameService(){
var service = {
handValue: handValue,
@@ -63,4 +56,5 @@
return service;
}
-})();
+
+export default GameService;
View
@@ -0,0 +1,11 @@
+import angular from 'angular';
+import GameDirective from './game.directive';
+import GameService from './game.service';
+
+let gameModule = angular.module('blackjack.game', []);
+
+gameModule
+ .directive('blackjackGame', GameDirective)
+ .factory('GameService', GameService);
+
+export default gameModule;
@@ -0,0 +1,9 @@
+import angular from 'angular';
+import PlayerService from './player.service';
+
+let playerModule = angular.module('blackjack.player', []);
+
+playerModule
+ .factory('PlayerService', PlayerService);
+
+export default playerModule;
@@ -1,7 +0,0 @@
-(function(){
- 'use strict';
-
- angular
- .module('blackjack.player', []);
-
-})();
Oops, something went wrong.