Last active
May 11, 2022 22:24
-
-
Save himetani/c1f12eea75bdbd628e0e to your computer and use it in GitHub Desktop.
Gulp + Nodemon + BrowserSync
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'), | |
exec = require('child_process').exec, | |
uglify = require('gulp-uglify'), | |
inject = require('gulp-inject'), | |
jshint = require('gulp-jshint'), | |
angularFilesort = require('gulp-angular-filesort') | |
bs = require('browser-sync').create(), | |
nodemon = require('gulp-nodemon'); | |
var paths = { | |
index : ['./client/index.html'], | |
angular : ['./client/assets/vendor/angular/*.js'], | |
vendor : ['./client/assets/vendor/*.js', './client/assets/vendor/*.css'], | |
app : ['./client/app/*.js'], | |
shared : ['./client/app/shared/*.js'], | |
components : ['./client/app/componets/*.js'] | |
}; | |
gulp.task('inject', function() { | |
return gulp.src(paths.index) | |
.pipe(inject(gulp.src(paths.angular).pipe(angularFilesort()), {name: 'angular'})) | |
.pipe(inject(gulp.src(paths.vendor, {read: false}), {name: 'vendor'})) | |
.pipe(inject(gulp.src(paths.app, {read:false}), {name: 'app'})) | |
.pipe(inject(gulp.src(paths.shared, {read: false}), {name: 'shared'})) | |
.pipe(inject(gulp.src(paths.components, {read:false}), {name: 'components'})) | |
.pipe(gulp.dest('./client')); | |
}); | |
gulp.task('browser-sync', ['nodemon'], function() { | |
var pathsArray = new Array(); | |
Object.keys(paths).forEach(function(key) { | |
pathsArray = pathsArray.concat(paths[key]); | |
}); | |
bs.init(null, { | |
proxy: "http://localhost:3000", | |
files: pathsArray, | |
browser: "google chrome", | |
port: 7000 | |
}); | |
}); | |
gulp.task('nodemon', function(cb) { | |
return nodemon({script: './server/app.js'}) | |
.on('start', function() { | |
cb(); | |
}) | |
.on('restart', function() { | |
console.log('nodemon restarted!'); | |
}); | |
}); | |
gulp.task('default', ['inject', 'browser-sync']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html class="no-js"> | |
<head> | |
<title></title> | |
<meta charset="utf-8"> | |
<!-- vendor:css --> | |
<link rel="stylesheet" href="/client/assets/vendor/bootstrap.min.css"> | |
<!-- endinject --> | |
</head> | |
<body ng-app="angularApp"> | |
<h2>Hello World!</h2><p>hello</p> | |
<div ng-view=""></div> | |
<!-- angular:js --> | |
<script src="/client/assets/vendor/angular/angular.min.js"></script> | |
<script src="/client/assets/vendor/angular/angular-route.min.js"></script> | |
<!-- endinject --> | |
<!-- vendor:js --> | |
<script src="/client/assets/vendor/ui-bootstrap-tpls-0.12.1.min.js"></script> | |
<!-- endinject --> | |
<!-- shared:js --> | |
<!-- endinject --> | |
<!-- app:js --> | |
<script src="/client/app/app.js"></script> | |
<!-- endinject --> | |
<!-- components:js --> | |
<!-- endinject --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment