diff --git a/Gulpfile.js b/Gulpfile.js index 9771dca..9939c99 100644 --- a/Gulpfile.js +++ b/Gulpfile.js @@ -3,18 +3,29 @@ var sync = require('run-sequence'); var browser = require('browser-sync'); var webpack = require('webpack-stream'); var todo = require('gulp-todoist'); +var path = require('path'); +var yargs = require('yargs').argv; +var tpl = require('gulp-template'); +var rename = require('gulp-rename'); /* map of paths for using with the tasks below */ var paths = { entry: 'client/app/app.js', - app: ['client/app/**/*.{js,styl,html}', 'client/index.html'], + app: ['client/app/**/*.{js,styl,html}', 'client/styles/**/*.styl'], js: 'client/app/**/*!(.spec.js).js', - styl: 'client/app/**/*.styl', + styl: ['client/app/**/*.styl', 'client/style/**/*.styl'], toCopy: ['client/index.html'], html: ['client/index.html', 'client/app/**/*.html'], - dest: 'dist' + dest: 'dist', + blankTemplates: 'templates/component/*.**' +}; + +// helper funciton +var resolveToComponents = function(glob){ + glob = glob || ''; + return path.join('client', 'app/components', glob); // app/components/{glob} }; gulp.task('todo', function() { @@ -23,13 +34,9 @@ gulp.task('todo', function() { }); gulp.task('build', ['todo'], function() { - //TODO - /* - fill this task out to take in entry file - and build using the webpack plugin. - the plugin takes the webpack.config as an arg. - be sure to stream the result to the destination path - */ + return gulp.src(paths.entry) + .pipe(webpack(require('./webpack.config'))) + .pipe(gulp.dest(paths.dest)); }); gulp.task('serve', function() { @@ -47,7 +54,7 @@ gulp.task('serve', function() { simple task to copy over needed files to dist */ gulp.task('copy', function() { - return gulp.src(paths.toCopy, { base: '.' }) + return gulp.src(paths.toCopy, { base: 'client' }) .pipe(gulp.dest(paths.dest)); }); @@ -56,9 +63,30 @@ task to watch files for changes and call build and copy tasks */ gulp.task('watch', function() { gulp.watch(paths.app, ['build', browser.reload]); - gulp.watch(paths.toCopy, ['copy']); + gulp.watch(paths.toCopy, ['copy', browser.reload]); +}); + +gulp.task('component', function(){ + var cap = function(val){ + return val.charAt(0).toUpperCase() + val.slice(1); + }; + + var name = yargs.name; + var parentPath = yargs.parent || ''; + var destPath = path.join(resolveToComponents(), parentPath, name); + + return gulp.src(paths.blankTemplates) + .pipe(tpl({ + name: name, + upCaseName: cap(name) + })) + .pipe(rename(function(path){ + path.basename = path.basename.replace('component', name); + })) + .pipe(gulp.dest(destPath)); }); + gulp.task('default', function(done) { sync('build', 'copy', 'serve', 'watch', done) }); diff --git a/client/app/app.directive.js b/client/app/app.directive.js new file mode 100644 index 0000000..465e012 --- /dev/null +++ b/client/app/app.directive.js @@ -0,0 +1,11 @@ +import './app.styl'; +import template from './app.html'; + +export const appDirective = ()=> { + return { + template, + restrict: 'E', + scope: {}, + replace: true + }; +}; diff --git a/client/app/app.html b/client/app/app.html new file mode 100644 index 0000000..d11064b --- /dev/null +++ b/client/app/app.html @@ -0,0 +1,20 @@ +