Skip to content

Commit

Permalink
fix(authPages): add separeted gulp tasks for separated pages
Browse files Browse the repository at this point in the history
  • Loading branch information
SashaSkywalker committed Jan 12, 2016
1 parent 64f90f8 commit 3bb5e41
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 19 deletions.
42 changes: 36 additions & 6 deletions gulp/inject.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ var _ = require('lodash');

var browserSync = require('browser-sync');

gulp.task('inject-reload', ['inject'], function() {
gulp.task('inject-reload', ['inject'], function () {
browserSync.reload();
});

gulp.task('inject', ['scripts', 'styles'], function () {
gulp.task('inject', ['scripts', 'styles', 'injectAuth', 'inject404'], function () {
var injectStyles = gulp.src([
path.join(conf.paths.tmp, '/serve/app/**/*.css'),
path.join(conf.paths.tmp, '/serve/app/main.css'),
path.join('!' + conf.paths.tmp, '/serve/app/vendor.css')
], { read: false });
], {read: false});

var injectScripts = gulp.src([
path.join(conf.paths.src, '/assets/js/**/*.js'),
Expand All @@ -28,16 +28,46 @@ gulp.task('inject', ['scripts', 'styles'], function () {
path.join('!' + conf.paths.src, '/app/**/*.spec.js'),
path.join('!' + conf.paths.src, '/app/**/*.mock.js'),
])
/*.pipe($.angularFilesort())*/.on('error', conf.errorHandler('AngularFilesort'));
/*.pipe($.angularFilesort())*/.on('error', conf.errorHandler('AngularFilesort'));

var injectOptions = {
ignorePath: [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
addRootSlash: false
};

return gulp.src(path.join(conf.paths.src, '/*.html'))
return gulp.src(path.join(conf.paths.src, '/index.html'))
.pipe($.inject(injectStyles, injectOptions))
.pipe($.inject(injectScripts, injectOptions))
.pipe(wiredep(_.extend({}, conf.wiredep)))
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
});

gulp.task('injectAuth', ['stylesAuth'], function () {
return injectAlone({
css: [path.join('!' + conf.paths.tmp, '/serve/app/vendor.css'), path.join(conf.paths.tmp, '/serve/app/auth.css')],
paths: [path.join(conf.paths.src, '/auth.html'), path.join(conf.paths.src, '/reg.html')]
})
});

gulp.task('inject404', ['styles404'], function () {
return injectAlone({
css: [path.join('!' + conf.paths.tmp, '/serve/app/vendor.css'), path.join(conf.paths.tmp, '/serve/app/404.css')],
paths: path.join(conf.paths.src, '/404.html')
})
});

var injectAlone = function (options) {
var injectStyles = gulp.src(
options.css
, {read: false});

var injectOptions = {
ignorePath: [conf.paths.src, path.join(conf.paths.tmp, '/serve')],
addRootSlash: false
};

return gulp.src(options.paths)
.pipe($.inject(injectStyles, injectOptions))
.pipe(wiredep(_.extend({}, conf.wiredep)))
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve')));
};
32 changes: 26 additions & 6 deletions gulp/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,36 @@ var $ = require('gulp-load-plugins')();
var wiredep = require('wiredep').stream;
var _ = require('lodash');

gulp.task('styles-reload', ['styles'], function() {
gulp.task('styles-reload', ['styles'], function () {
return buildStyles()
.pipe(browserSync.stream());
});

gulp.task('styles', function() {
gulp.task('styles', function () {
return buildStyles();
});

var buildStyles = function() {
gulp.task('stylesAuth', function () {
return buildAloneStyles(path.join(conf.paths.src, '/sass/auth.scss'));
});
gulp.task('styles404', function () {
return buildAloneStyles(path.join(conf.paths.src, '/sass/404.scss'));
});

var buildStyles = function () {
var sassOptions = {
style: 'expanded'
};

var injectFiles = gulp.src([
path.join(conf.paths.src, '/sass/**/_*.scss'),
'!' + path.join(conf.paths.src, '/sass/theme/conf/**/*.scss')
], { read: false });
'!' + 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')
], {read: false});

var injectOptions = {
transform: function(filePath) {
transform: function (filePath) {
filePath = filePath.replace(conf.paths.src + '/sass/', '');
return '@import "' + filePath + '";';
},
Expand All @@ -51,3 +60,14 @@ var buildStyles = function() {
.pipe($.sourcemaps.write())
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/app/')));
};

var buildAloneStyles = function (paths) {
var sassOptions = {
style: 'expanded'
};

return gulp.src([paths])
.pipe($.sass(sassOptions)).on('error', conf.errorHandler('Sass'))
.pipe($.autoprefixer()).on('error', conf.errorHandler('Autoprefixer'))
.pipe(gulp.dest(path.join(conf.paths.tmp, '/serve/app/')));
};
6 changes: 5 additions & 1 deletion src/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
<link rel="icon" type="image/png" sizes="96x96" href="img/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">

<link rel="stylesheet" href="css/404.min.css">
<!-- build:css({.tmp/serve,src}) styles/404.css -->
<!-- inject:css -->
<!-- css files will be automatically insert here -->
<!-- endinject -->
<!-- endbuild -->
</head>
<body>
<div class="page-not-found-modal">
Expand Down
12 changes: 11 additions & 1 deletion src/auth.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
<link rel="icon" type="image/png" sizes="96x96" href="img/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">

<link rel="stylesheet" href="css/auth.min.css">
<!-- build:css({.tmp/serve,src}) styles/vendor.css -->
<!-- bower:css -->
<!-- run `gulp inject` to automatically populate bower styles dependencies -->
<!-- endbower -->
<!-- endbuild -->

<!-- build:css({.tmp/serve,src}) styles/auth.css -->
<!-- inject:css -->
<!-- css files will be automatically insert here -->
<!-- endinject -->
<!-- endbuild -->
</head>
<body>
<main class="auth-main">
Expand Down
12 changes: 11 additions & 1 deletion src/reg.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
<link rel="icon" type="image/png" sizes="96x96" href="img/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="img/favicon-16x16.png">

<link rel="stylesheet" href="css/auth.min.css">
<!-- build:css({.tmp/serve,src}) styles/vendor.css -->
<!-- bower:css -->
<!-- run `gulp inject` to automatically populate bower styles dependencies -->
<!-- endbower -->
<!-- endbuild -->

<!-- build:css({.tmp/serve,src}) styles/auth.css -->
<!-- inject:css -->
<!-- css files will be automatically insert here -->
<!-- endinject -->
<!-- endbuild -->
</head>
<body>
<main class="auth-main">
Expand Down
3 changes: 1 addition & 2 deletions src/sass/404.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@import "_variables.scss";
@import "_mixins.scss";
@import "common.scss";

html {
position: relative;
Expand Down
3 changes: 1 addition & 2 deletions src/sass/auth.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@import "theme/_variables.scss";
@import "theme/_mixins.scss";
@import "common.scss";
@import "theme/_socicon.scss";
@import "theme/_layout.scss";

Expand Down

0 comments on commit 3bb5e41

Please sign in to comment.