-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 364f677
Showing
46 changed files
with
697 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [ "es2015" ] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
|
||
[*.{js,json,scss,css,hbs}] | ||
indent_style = space | ||
indent_size = 2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ENV=dev |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"installedESLint": true, | ||
"extends": "standard", | ||
"env": { | ||
"browser": true, | ||
"node": true | ||
}, | ||
"parser": "babel-eslint", | ||
"plugins": [ | ||
"standard", | ||
"promise" | ||
], | ||
"globals": { | ||
"$": true, | ||
"_": true, | ||
"App": true, | ||
"Backbone": true, | ||
"Marionette": true, | ||
"Radio": true, | ||
"alert": true, | ||
"localStorage": true, | ||
"moment": true | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.DS_Store | ||
.env | ||
node_modules/ | ||
public/ | ||
npm-debug.log |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import dotenv from 'dotenv' | ||
|
||
dotenv.config({ silent: true }) | ||
|
||
let isDevelopment = (process.env.ENV && process.env.ENV !== 'production') | ||
|
||
let config = { | ||
|
||
environment: isDevelopment ? 'development' : 'production', | ||
development: isDevelopment, | ||
|
||
browsersync: { | ||
port: 9000, | ||
uiport: 9001 | ||
}, | ||
|
||
browserify: { | ||
app: 'main.js', | ||
vendor: 'vendor.js' | ||
}, | ||
|
||
// fonts: { | ||
// src: [ | ||
// 'src/resources/fonts/**/*', | ||
// 'node_modules/font-awesome/fonts/**/*' | ||
// ], | ||
// dest: 'public/fonts' | ||
// }, | ||
|
||
gzip: { | ||
src: 'public/**/*.{html,xml,json,css,js,js.map,css.map}', | ||
dest: 'public/', | ||
options: {} | ||
}, | ||
|
||
html: { | ||
src: 'src/**/*.html', | ||
dest: 'public', | ||
cachebust: 'public/**/*.html' | ||
}, | ||
|
||
images: { | ||
src: 'src/resources/images/**/*', | ||
dest: 'public/img' | ||
}, | ||
|
||
sass: { | ||
src: 'src/resources/styles', | ||
dest: 'public/css', | ||
glob: 'src/resources/styles/**/*.scss', | ||
includePaths: [ | ||
'node_modules/normalize-scss/sass', | ||
'node_modules' | ||
] | ||
}, | ||
|
||
scripts: { | ||
src: 'src', | ||
dest: 'public/js', | ||
glob: 'src/**/*.js' | ||
}, | ||
|
||
paths: { | ||
src: 'src', | ||
dest: 'public' | ||
} | ||
|
||
} | ||
|
||
export default config |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import gulp from 'gulp' | ||
|
||
import fs from 'fs' | ||
|
||
import gulpPlugins from 'gulp-load-plugins' | ||
import config from './config/' | ||
|
||
// Import gulp tasks | ||
let tasks = [] | ||
let plugins = gulpPlugins() | ||
|
||
let wrap = function (task, ...done) { | ||
return task.bind(this, gulp, plugins, config, ...done) | ||
} | ||
|
||
fs.readdirSync(`${process.cwd()}/gulp/tasks/`).forEach(task => { | ||
let taskName = task.replace('.js', '') | ||
tasks[taskName] = require('./tasks/' + task).default | ||
}) | ||
|
||
// Task assignment | ||
gulp.task('browserify:app', wrap(tasks.browserify, config.browserify.app)) | ||
gulp.task('browserify:vendor', wrap(tasks.browserify, config.browserify.vendor)) | ||
gulp.task('browsersync', wrap(tasks.browsersync)) | ||
gulp.task('build', [ 'clean' ], wrap(tasks.build)) | ||
gulp.task('cachebust', wrap(tasks.cachebust)) | ||
gulp.task('clean', wrap(tasks.clean)) | ||
// gulp.task('copy:fonts', wrap(tasks.fonts)) | ||
gulp.task('copy:html', wrap(tasks.html)) | ||
gulp.task('copy:images', wrap(tasks.images)) | ||
gulp.task('default', wrap(tasks.default)) | ||
gulp.task('development', [ 'build' ], wrap(tasks.development)) | ||
gulp.task('eslint', wrap(tasks.eslint)) | ||
gulp.task('gzip', wrap(tasks.gzip)) | ||
gulp.task('production', [ 'build' ], wrap(tasks.production)) | ||
gulp.task('sass', wrap(tasks.sass)) | ||
gulp.task('watch', [ 'browsersync' ], wrap(tasks.watch)) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import browserify from 'browserify' | ||
|
||
import babelify from 'babelify' | ||
import envify from 'envify' | ||
import hbsfy from 'hbsfy' | ||
import watchify from 'watchify' | ||
|
||
import browserSync from 'browser-sync' | ||
import buffer from 'vinyl-buffer' | ||
import source from 'vinyl-source-stream' | ||
|
||
import errorHandler from '../utils/errorHandler' | ||
import bundleLogger from '../utils/bundleLogger' | ||
|
||
let browserifyTask = (gulp, plugins, config, file, done) => { | ||
let bundler = browserify({ | ||
entries: [ `${config.scripts.src}/${file}` ], | ||
debug: config.development | ||
}) | ||
|
||
if (config.development) { | ||
bundler = watchify(bundler) | ||
bundler.on('update', rebundle) | ||
} | ||
|
||
const transforms = [ | ||
{ name: babelify, options: {} }, | ||
{ name: hbsfy, options: {} }, | ||
{ name: envify, options: {} } | ||
] | ||
|
||
transforms.forEach(transform => { | ||
bundler.transform(transform.name, transform.options) | ||
}) | ||
|
||
function rebundle () { | ||
bundleLogger.start(file) | ||
const stream = bundler.bundle() | ||
|
||
return stream | ||
.on('error', errorHandler.bind(this)) | ||
.on('end', bundleLogger.end.bind(this, file)) | ||
.pipe(source(file)) | ||
.pipe(plugins.if(config.development, buffer())) | ||
.pipe(plugins.if(config.development, plugins.sourcemaps.init({ loadMaps: true }))) | ||
.pipe(plugins.if(!config.development, plugins.streamify(plugins.uglify({ | ||
compress: { drop_console: true } | ||
})))) | ||
.pipe(plugins.if(config.development, plugins.sourcemaps.write('./'))) | ||
.pipe(gulp.dest(config.scripts.dest)) | ||
.pipe(browserSync.stream()) | ||
} | ||
|
||
return rebundle() | ||
} | ||
|
||
export default browserifyTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import browserSync from 'browser-sync' | ||
import historyFallback from 'connect-history-api-fallback' | ||
|
||
let browserSyncTask = (gulp, plugins, config) => { | ||
browserSync.init({ | ||
server: { | ||
baseDir: config.paths.dest, | ||
middleware: [ historyFallback() ] | ||
}, | ||
open: false, | ||
notify: false, | ||
xip: true, | ||
port: config.browsersync.port, | ||
ui: { | ||
port: config.browsersync.uiport | ||
} | ||
}) | ||
} | ||
|
||
export default browserSyncTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import runSequence from 'run-sequence' | ||
|
||
let buildTask = (gulp, plugins, config, done) => { | ||
runSequence([ | ||
// 'copy:fonts', | ||
'copy:images', | ||
'copy:html', | ||
'sass' | ||
], [ | ||
'browserify:vendor', | ||
'browserify:app' | ||
], done) | ||
} | ||
|
||
export default buildTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import browserSync from 'browser-sync' | ||
|
||
let cacheBustTask = (gulp, plugins, config) => { | ||
return gulp.src(config.html.cachebust) | ||
.pipe(plugins.cacheBust()) | ||
.pipe(gulp.dest(config.html.dest)) | ||
.pipe(browserSync.stream()) | ||
} | ||
|
||
export default cacheBustTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import del from 'del' | ||
|
||
let cleanTask = (gulp, plugins, config) => { | ||
return del.sync(`${config.paths.dest}/**/*`) | ||
} | ||
|
||
export default cleanTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import runSequence from 'run-sequence' | ||
|
||
let defaultTask = (gulp, plugins, config, done) => { | ||
plugins.util.log(`${plugins.util.colors.yellow('Starting', config.environment, 'build!')}`) | ||
runSequence(`${config.environment}`, done) | ||
} | ||
|
||
export default defaultTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import runSequence from 'run-sequence' | ||
|
||
let developmentTask = (gulp, plugins, config, done) => { | ||
runSequence('watch') | ||
} | ||
|
||
export default developmentTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
let eslintTask = (gulp, plugins, config) => { | ||
return gulp.src(config.scripts.glob) | ||
.pipe(plugins.eslint()) | ||
.pipe(plugins.eslint.format()) | ||
.pipe(plugins.eslint.failAfterError()) | ||
} | ||
|
||
export default eslintTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import browserSync from 'browser-sync' | ||
|
||
let fontsTask = (gulp, plugins, config) => { | ||
return gulp.src(config.fonts.src) | ||
.pipe(plugins.changed(config.fonts.dest)) | ||
.pipe(gulp.dest(config.fonts.dest)) | ||
.pipe(browserSync.stream()) | ||
} | ||
|
||
export default fontsTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
let gzipTask = (gulp, plugins, config) => { | ||
return gulp.src(config.gzip.src) | ||
.pipe(plugins.gzip(config.gzip.options)) | ||
.pipe(gulp.dest(config.gzip.dest)) | ||
} | ||
|
||
export default gzipTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import browserSync from 'browser-sync' | ||
|
||
let htmlTask = (gulp, plugins, config) => { | ||
return gulp.src(config.html.src) | ||
.pipe(plugins.changed(config.html.dest)) | ||
.pipe(gulp.dest(config.html.dest)) | ||
.pipe(browserSync.stream()) | ||
} | ||
|
||
export default htmlTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import browserSync from 'browser-sync' | ||
|
||
let imagesTask = (gulp, plugins, config) => { | ||
return gulp.src(config.images.src) | ||
.pipe(plugins.changed(config.images.dest)) | ||
.pipe(plugins.if(!config.development, plugins.imagemin())) | ||
.pipe(gulp.dest(config.images.dest)) | ||
.pipe(browserSync.stream()) | ||
} | ||
|
||
export default imagesTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import runSequence from 'run-sequence' | ||
|
||
let productionTask = (gulp, plugins, config, done) => { | ||
runSequence('gzip', 'cachebust', done) | ||
} | ||
|
||
export default productionTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import browserSync from 'browser-sync' | ||
|
||
import errorHandler from '../utils/errorHandler' | ||
|
||
let sassTask = (gulp, plugins, config) => { | ||
return gulp.src(config.sass.glob) | ||
.pipe(plugins.if(config.development, plugins.sourcemaps.init())) | ||
.pipe(plugins.sassGlob()) | ||
.pipe(plugins.sass({ | ||
sourceComments: config.development, | ||
outputStyle: config.development ? 'nested' : 'compressed', | ||
includePaths: config.sass.includePaths | ||
})) | ||
.on('error', errorHandler) | ||
.pipe(plugins.autoprefixer({ | ||
browsers: [ 'last 2 versions', '> 1%', 'ie 8' ] | ||
})) | ||
.pipe(plugins.if(config.development, plugins.sourcemaps.write('./'))) | ||
.pipe(gulp.dest(config.sass.dest)) | ||
.pipe(browserSync.stream()) | ||
} | ||
|
||
export default sassTask |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let watchTask = (gulp, plugins, config) => { | ||
// gulp.watch(config.fonts.src, [ 'copy:fonts' ]) | ||
gulp.watch(config.html.src, [ 'copy:html' ]) | ||
gulp.watch(config.images.src, [ 'copy:images' ]) | ||
gulp.watch(config.sass.glob, [ 'sass' ]) | ||
// gulp.watch(config.scripts.glob, [ 'eslint' ]) | ||
} | ||
|
||
export default watchTask |
Oops, something went wrong.