diff --git a/gulp/scripts.js b/gulp/scripts.js
index 585e4fc8a..0557a50fb 100644
--- a/gulp/scripts.js
+++ b/gulp/scripts.js
@@ -9,18 +9,24 @@ var browserSync = require('browser-sync');
var $ = require('gulp-load-plugins')();
-gulp.task('scripts-reload', function() {
- return buildScripts()
- .pipe(browserSync.stream());
+gulp.task('scripts-reload', function () {
+
+ var bsOptions = {};
+ if (conf._gulpWatchEvent) {
+ bsOptions.match = conf._gulpWatchEvent.path;
+ }
+
+ return buildScripts()
+ .pipe(browserSync.stream(bsOptions));
});
-gulp.task('scripts', function() {
- return buildScripts();
+gulp.task('scripts', function () {
+ return buildScripts();
});
function buildScripts() {
- return gulp.src(path.join(conf.paths.src, '/app/**/*.js'))
- .pipe($.eslint())
- .pipe($.eslint.format())
- .pipe($.size())
+ return gulp.src(path.join(conf.paths.src, '/app/**/*.js'))
+ .pipe($.eslint())
+ .pipe($.eslint.format())
+ .pipe($.size())
};
diff --git a/gulp/server.js b/gulp/server.js
index 98008677f..651c8fbc9 100644
--- a/gulp/server.js
+++ b/gulp/server.js
@@ -47,6 +47,18 @@ browserSync.use(browserSyncSpa({
selector: '[ng-app]'// Only needed for angular apps
}));
+var bsInjular = require('bs-injular');
+
+browserSync.use(bsInjular, {
+ templates: ['/app/pages/**/*.html','/app/my-module/**/*.html'],
+ controllers: ['/app/pages/**/*.controller.js','/app/my-module/**/*.controller.js'],
+ directives: ['/app/pages/**/*.directive.js','/app/my-module/**/*.directive.js'],
+ filters: ['/app/pages/**/*.filter.js','/app/pages/**/*.filter.js'],
+ angularFile: '/bower_components/angular/angular.js',
+ moduleFile: '/app/app.js',
+ ngApp: 'BlurAdmin'
+});
+
gulp.task('serve', ['watch'], function () {
browserSyncInit([path.join(conf.paths.tmp, '/serve'), conf.paths.src]);
});
diff --git a/gulp/styles.js b/gulp/styles.js
index a744fab5d..4c39b2222 100644
--- a/gulp/styles.js
+++ b/gulp/styles.js
@@ -34,6 +34,7 @@ var buildStyles = function () {
var injectFiles = gulp.src([
path.join(conf.paths.src, '/sass/**/_*.scss'),
+ path.join(conf.paths.src, '/app/**/*.scss'),
'!' + path.join(conf.paths.src, '/sass/theme/conf/**/*.scss'),
'!' + path.join(conf.paths.src, '/sass/404.scss'),
'!' + path.join(conf.paths.src, '/sass/auth.scss')
diff --git a/gulp/watch.js b/gulp/watch.js
index d14055837..fa240a94d 100644
--- a/gulp/watch.js
+++ b/gulp/watch.js
@@ -16,7 +16,9 @@ gulp.task('watch', ['inject'], function () {
gulp.watch([
path.join(conf.paths.src, '/sass/**/*.css'),
- path.join(conf.paths.src, '/sass/**/*.scss')
+ path.join(conf.paths.src, '/sass/**/*.scss'),
+ path.join(conf.paths.src, '/app/**/*.scss')
+
], function(event) {
if(isOnlyChange(event)) {
gulp.start('styles-reload');
@@ -26,11 +28,13 @@ gulp.task('watch', ['inject'], function () {
});
gulp.watch(path.join(conf.paths.src, '/app/**/*.js'), function(event) {
+ conf._gulpWatchEvent = event;
if(isOnlyChange(event)) {
gulp.start('scripts-reload');
} else {
gulp.start('inject-reload');
}
+ delete conf._gulpWatchEvent;
});
gulp.watch(path.join(conf.paths.src, '/app/**/*.html'), function(event) {
diff --git a/package.json b/package.json
index a062cac85..e84304284 100644
--- a/package.json
+++ b/package.json
@@ -2,8 +2,9 @@
"name": "blur_admin",
"version": "1.2.0",
"devDependencies": {
- "browser-sync": "~2.9.11",
+ "browser-sync": "^2.18.2",
"browser-sync-spa": "~1.0.3",
+ "bs-injular": "^0.6.0",
"chalk": "~1.1.1",
"del": "~2.0.2",
"eslint-plugin-angular": "~0.12.0",
diff --git a/src/app/app.js b/src/app/app.js
index 4a34c749e..49bd033b6 100644
--- a/src/app/app.js
+++ b/src/app/app.js
@@ -14,5 +14,6 @@ angular.module('BlurAdmin', [
'angular-progress-button-styles',
'BlurAdmin.theme',
- 'BlurAdmin.pages'
+ 'BlurAdmin.pages',
+ 'my-module'
]);
\ No newline at end of file
diff --git a/src/app/my-module/my-module.js b/src/app/my-module/my-module.js
new file mode 100644
index 000000000..0966c24b3
--- /dev/null
+++ b/src/app/my-module/my-module.js
@@ -0,0 +1,17 @@
+
+/**
+ * Created by sguilly on 23/10/16.
+ */
+(function () {
+ 'use strict';
+
+ /* @ngdoc object
+ * @name models
+ * @description
+ *
+ */
+ angular
+ .module('my-module', [
+ 'my-page'
+ ]);
+}());
\ No newline at end of file
diff --git a/src/app/my-module/my-page/my-page.controller.js b/src/app/my-module/my-page/my-page.controller.js
new file mode 100644
index 000000000..8b6e5401c
--- /dev/null
+++ b/src/app/my-module/my-page/my-page.controller.js
@@ -0,0 +1,24 @@
+/**
+ * Created by sguilly on 22/11/16.
+ */
+(function () {
+ 'use strict';
+
+ /**
+ * @ngdoc object
+ * @name category.controller:CategoriesCtrl
+ *
+ * @description
+ *
+ */
+ angular
+ .module('my-page')
+ .controller('MyPageCtrl', MyPageCtrl);
+
+ function MyPageCtrl($scope, $state,MyPageService) {
+
+ var vm = this;
+ vm.ctrlName = 'My Hot Reload Page :)';
+
+ }
+}());
diff --git a/src/app/my-module/my-page/my-page.directive.js b/src/app/my-module/my-page/my-page.directive.js
new file mode 100644
index 000000000..cb4e0f401
--- /dev/null
+++ b/src/app/my-module/my-page/my-page.directive.js
@@ -0,0 +1,46 @@
+/**
+ * Created by sguilly on 21/10/16.
+ */
+
+/**
+ * Created by sguilly on 19/10/16.
+ */
+
+(function () {
+ 'use strict';
+
+ //
+
+ angular
+ .module('my-page')
+ .directive('myPageDirective', myPageDirective);
+
+ function myPageDirective() {
+ var directive = {
+ restrict: 'EA',
+ template: '{{vm.text}} - {{vm.serviceText}}
'
+ ,
+ scope: {
+
+ text: '=?',
+ ngModel: '=',
+
+ },
+ require: 'ngModel',
+ controller: MyPageDirectiveCtrl,
+ controllerAs: 'vm',
+ bindToController: true
+ };
+
+ return directive;
+ }
+
+ MyPageDirectiveCtrl.$inject = ['HotReloadService'];
+ function MyPageDirectiveCtrl(MyPageService) {
+ var vm = this;
+
+ vm.serviceText = MyPageService.getText()
+
+ }
+
+}());
diff --git a/src/app/my-module/my-page/my-page.html b/src/app/my-module/my-page/my-page.html
new file mode 100644
index 000000000..1f9f11650
--- /dev/null
+++ b/src/app/my-module/my-page/my-page.html
@@ -0,0 +1,9 @@
+
+
+ {{vm.ctrlName}}
+
+
+
+
+
+
diff --git a/src/app/my-module/my-page/my-page.module.js b/src/app/my-module/my-page/my-page.module.js
new file mode 100644
index 000000000..c5b6ca8d6
--- /dev/null
+++ b/src/app/my-module/my-page/my-page.module.js
@@ -0,0 +1,16 @@
+/**
+ * Created by sguilly on 22/11/16.
+ */
+(function () {
+ 'use strict';
+
+ /* @ngdoc object
+ * @name categories
+ * @description
+ *
+ */
+ angular
+ .module('my-page', [
+ 'ui.router'
+ ]);
+}());
\ No newline at end of file
diff --git a/src/app/my-module/my-page/my-page.routes.js b/src/app/my-module/my-page/my-page.routes.js
new file mode 100644
index 000000000..39f7a7784
--- /dev/null
+++ b/src/app/my-module/my-page/my-page.routes.js
@@ -0,0 +1,24 @@
+/**
+ * Created by sguilly on 22/11/16.
+ */
+(function () {
+ 'use strict';
+
+ angular
+ .module('hotReloadPage')
+ .config(config);
+
+ function config($stateProvider) {
+ $stateProvider
+ .state('my-page', {
+ url: '/my-page',
+ templateUrl: 'app/my-module/my-page/my-page.html',
+ controller: 'MyPageCtrl',
+ controllerAs: 'vm',
+ title: 'my-page',
+ sidebarMeta: {
+ order: 0,
+ },
+ });
+ }
+}());
\ No newline at end of file
diff --git a/src/app/my-module/my-page/my-page.scss b/src/app/my-module/my-page/my-page.scss
new file mode 100644
index 000000000..37eb3aec0
--- /dev/null
+++ b/src/app/my-module/my-page/my-page.scss
@@ -0,0 +1,13 @@
+.blue {
+ background-color: #777aff;
+ color: white;
+ margin : 20px;
+ padding : 20px;
+}
+
+.red {
+ background-color: #e81c2e;
+ color: white;
+ margin : 20px;
+ padding : 20px;
+}
\ No newline at end of file
diff --git a/src/app/my-module/my-page/my-page.service.js b/src/app/my-module/my-page/my-page.service.js
new file mode 100644
index 000000000..0d22b56d8
--- /dev/null
+++ b/src/app/my-module/my-page/my-page.service.js
@@ -0,0 +1,16 @@
+/**
+ * Created by sguilly on 22/11/16.
+ */
+
+'use strict';
+
+angular.module('my-page')
+
+ .service('MyPageService', function () {
+
+ this.getText = function()
+ {
+ return 'MyService'
+ }
+
+ });
\ No newline at end of file
diff --git a/src/app/pages/hotReload/hotReload.js b/src/app/pages/hotReload/hotReload.js
new file mode 100644
index 000000000..74d3b1a9d
--- /dev/null
+++ b/src/app/pages/hotReload/hotReload.js
@@ -0,0 +1,17 @@
+
+/**
+ * Created by sguilly on 23/10/16.
+ */
+(function () {
+ 'use strict';
+
+ /* @ngdoc object
+ * @name models
+ * @description
+ *
+ */
+ angular
+ .module('BlurAdmin.pages.hotReload', [
+ 'hotReloadPage'
+ ]);
+}());
\ No newline at end of file
diff --git a/src/app/pages/hotReload/hotReloadPage/hotReload.controller.js b/src/app/pages/hotReload/hotReloadPage/hotReload.controller.js
new file mode 100644
index 000000000..6e15f3c8e
--- /dev/null
+++ b/src/app/pages/hotReload/hotReloadPage/hotReload.controller.js
@@ -0,0 +1,24 @@
+/**
+ * Created by sguilly on 22/11/16.
+ */
+(function () {
+ 'use strict';
+
+ /**
+ * @ngdoc object
+ * @name category.controller:CategoriesCtrl
+ *
+ * @description
+ *
+ */
+ angular
+ .module('hotReloadPage')
+ .controller('HotReloadCtrl', HotReloadCtrl);
+
+ function HotReloadCtrl($scope, $state,MyPageService) {
+
+ var vm = this;
+ vm.ctrlName = 'Hot Reload Page';
+
+ }
+}());
diff --git a/src/app/pages/hotReload/hotReloadPage/hotReload.directive.js b/src/app/pages/hotReload/hotReloadPage/hotReload.directive.js
new file mode 100644
index 000000000..368cc2984
--- /dev/null
+++ b/src/app/pages/hotReload/hotReloadPage/hotReload.directive.js
@@ -0,0 +1,46 @@
+/**
+ * Created by sguilly on 21/10/16.
+ */
+
+/**
+ * Created by sguilly on 19/10/16.
+ */
+
+(function () {
+ 'use strict';
+
+ //
+
+ angular
+ .module('hotReloadPage')
+ .directive('hotReloadDirective', myPageDirective);
+
+ function myPageDirective() {
+ var directive = {
+ restrict: 'EA',
+ template: '{{vm.text}} - {{vm.serviceText}}
'
+ ,
+ scope: {
+
+ text: '=?',
+ ngModel:'=',
+
+ },
+ require: 'ngModel',
+ controller: HotReloadDirectiveCtrl,
+ controllerAs: 'vm',
+ bindToController: true
+ };
+
+ return directive;
+ }
+
+ HotReloadDirectiveCtrl.$inject = ['HotReloadService'];
+ function HotReloadDirectiveCtrl(HotReloadService) {
+ var vm = this;
+
+ vm.serviceText = HotReloadService.getText()
+
+ }
+
+}());
diff --git a/src/app/pages/hotReload/hotReloadPage/hotReload.html b/src/app/pages/hotReload/hotReloadPage/hotReload.html
new file mode 100644
index 000000000..d4267385e
--- /dev/null
+++ b/src/app/pages/hotReload/hotReloadPage/hotReload.html
@@ -0,0 +1,47 @@
+
+
+ {{vm.ctrlName}}
+
+
+
+
+
+
+
+
+
+
AngularJS 1.x hot reloading. This is a plugin for the awesome BrowserSync and bs-injular libs.
+
+
+
+ This supports template, controller, directive, component and filter injection.
+
+
+
+ See https://github.com/tfoxy/bs-injular for more details
+
+
+
+
+
+ Configuration in gulp/server.js
+
+
+
+
+
+
diff --git a/src/app/pages/hotReload/hotReloadPage/hotReload.module.js b/src/app/pages/hotReload/hotReloadPage/hotReload.module.js
new file mode 100644
index 000000000..e15cbfde1
--- /dev/null
+++ b/src/app/pages/hotReload/hotReloadPage/hotReload.module.js
@@ -0,0 +1,16 @@
+/**
+ * Created by sguilly on 22/11/16.
+ */
+(function () {
+ 'use strict';
+
+ /* @ngdoc object
+ * @name categories
+ * @description
+ *
+ */
+ angular
+ .module('hotReloadPage', [
+ 'ui.router'
+ ]);
+}());
\ No newline at end of file
diff --git a/src/app/pages/hotReload/hotReloadPage/hotReload.routes.js b/src/app/pages/hotReload/hotReloadPage/hotReload.routes.js
new file mode 100644
index 000000000..4d8696a55
--- /dev/null
+++ b/src/app/pages/hotReload/hotReloadPage/hotReload.routes.js
@@ -0,0 +1,24 @@
+/**
+ * Created by sguilly on 22/11/16.
+ */
+(function () {
+ 'use strict';
+
+ angular
+ .module('hotReloadPage')
+ .config(config);
+
+ function config($stateProvider) {
+ $stateProvider
+ .state('hotReload', {
+ url: '/hotReload',
+ templateUrl: 'app/pages/hotReload/hotReloadPage/hotReload.html',
+ controller: 'HotReloadCtrl',
+ controllerAs: 'vm',
+ title: 'hotReloadPage',
+ sidebarMeta: {
+ order: 0,
+ },
+ });
+ }
+}());
\ No newline at end of file
diff --git a/src/app/pages/hotReload/hotReloadPage/hotReload.scss b/src/app/pages/hotReload/hotReloadPage/hotReload.scss
new file mode 100644
index 000000000..38faef8ba
--- /dev/null
+++ b/src/app/pages/hotReload/hotReloadPage/hotReload.scss
@@ -0,0 +1,7 @@
+.blue {
+ background-color: #777aff;
+}
+
+.red {
+ background-color: #e81c2e;
+}
\ No newline at end of file
diff --git a/src/app/pages/hotReload/hotReloadPage/hotReload.service.js b/src/app/pages/hotReload/hotReloadPage/hotReload.service.js
new file mode 100644
index 000000000..78c98d35e
--- /dev/null
+++ b/src/app/pages/hotReload/hotReloadPage/hotReload.service.js
@@ -0,0 +1,16 @@
+/**
+ * Created by sguilly on 22/11/16.
+ */
+
+'use strict';
+
+angular.module('hotReloadPage')
+
+ .service('HotReloadService', function () {
+
+ this.getText = function()
+ {
+ return '[hotReload service text]'
+ }
+
+ });
\ No newline at end of file
diff --git a/src/app/pages/pages.module.js b/src/app/pages/pages.module.js
index ea11f4031..8dab5e960 100644
--- a/src/app/pages/pages.module.js
+++ b/src/app/pages/pages.module.js
@@ -16,6 +16,7 @@
'BlurAdmin.pages.charts',
'BlurAdmin.pages.maps',
'BlurAdmin.pages.profile',
+ 'BlurAdmin.pages.hotReload',
])
.config(routeConfig);