forked from udacity/mws-restaurant-stage-3
-
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.
Merge pull request #8 from mejarc/7-gulp
7 gulp
- Loading branch information
Showing
56 changed files
with
169 additions
and
20 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,7 @@ | ||
const presets = [ | ||
["@babel/env", { | ||
}, | ||
useBuiltIns: "usage"] | ||
]; | ||
|
||
module.exports = { presets }; |
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
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,117 @@ | ||
var gulp = require('gulp'); | ||
var concat = require('gulp-concat'); | ||
var sourcemaps = require('gulp-sourcemaps'); | ||
var useref = require('gulp-useref'); | ||
var del = require('del'); | ||
var babel = require('gulp-babel'); | ||
var uglify = require('gulp-uglify'); | ||
|
||
// var gutil = require('gulp-util'); | ||
var browserSync = require('browser-sync').create(); | ||
var webpack = require('webpack'); | ||
var WebpackDevServer = require('webpack-dev-server'); | ||
var webpackConfig = require('./webpack.config.js'); | ||
var stream = require('webpack-stream'); | ||
|
||
var paths = { | ||
styles: { | ||
src: 'src/css/**/*.css', | ||
dest: 'dist/css/' | ||
}, | ||
scripts: { | ||
src: 'src/js/**/*.js', | ||
dest: 'dist/js/' | ||
}, | ||
html: { | ||
src: 'src/*.html', | ||
dest: 'dist/' | ||
}, | ||
images: { | ||
src: 'src/img/**/*.jpg', | ||
dest: 'dist/img/' | ||
} | ||
}; | ||
|
||
// add tasks from incumbent Gruntfile | ||
require('gulp-grunt')(gulp, { | ||
prefix: 'stage-1-' | ||
}); | ||
|
||
gulp.task('default', [ | ||
'stage-1-default' | ||
] ); | ||
|
||
// utility | ||
function clean() { | ||
return del(['dist']); | ||
} | ||
|
||
// concatentate CSS; copy to /dist/css; TODO: minify | ||
function styles() { | ||
return (gulp.src(paths.styles.src)) | ||
.pipe(concat('all.min.css')) | ||
.pipe(gulp.dest(paths.styles.dest)); | ||
} | ||
|
||
// transpile JS; concatentate; minify; copy to /dist/js | ||
function scripts() { | ||
return gulp.src(paths.scripts.src) | ||
.pipe(sourcemaps.init()) | ||
.pipe(babel({ | ||
presets: ['@babel/env'] | ||
})) | ||
.pipe(concat('all.min.js')) | ||
.pipe(uglify()) | ||
.pipe(sourcemaps.write('.')) | ||
.pipe(gulp.dest(paths.scripts.dest)); | ||
} | ||
// copy HTML to /dist; change script and CSS links | ||
function html() { | ||
return (gulp.src(paths.html.src)) | ||
.pipe(useref()) | ||
.pipe(gulp.dest(paths.html.dest)); | ||
} | ||
|
||
// copy /img to /dist | ||
function images() { | ||
return (gulp.src(paths.images.src)) | ||
.pipe(gulp.dest(paths.images.dest)); | ||
} | ||
|
||
exports.clean = clean; | ||
exports.styles = styles; | ||
exports.scripts = scripts; | ||
exports.html = html; | ||
exports.images = images; | ||
|
||
|
||
gulp.task('useref', () => { | ||
return gulp.src(paths.html.src) | ||
.pipe(useref()) | ||
.pipe(uglify()) | ||
.pipe(gulp.dest(paths.html.dest)) | ||
}); | ||
|
||
|
||
gulp.task('browserSync', () => { | ||
browserSync.init({ | ||
server: { | ||
baseDir: 'src' | ||
} | ||
}); | ||
}); | ||
|
||
gulp.task('watch', ['browserSync'], () => { | ||
gulp.watch('src/js/**/*.js', browserSync.reload); | ||
gulp.watch('src/*.html', browserSync.reload); | ||
gulp.watch('src/css/**/*.css', browserSync.reload); | ||
}); | ||
|
||
gulp.task('webpack', [], () => { | ||
return gulp.src(path.ALL) | ||
.pipe(sourcemaps.init()) | ||
.pipe(stream(webpackConfig)) | ||
.pipe(uglify()) // minification | ||
.pipe(sourcemaps.write()) | ||
.pipe(gulp.dest(path.DEST_BUILD)) | ||
}); |
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 |
---|---|---|
@@ -1,21 +1,41 @@ | ||
{ | ||
"name": "mws-restaurant-stage-2", | ||
"version": "0.1.0", | ||
"private": true, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/mejarc/mws-restaurant-stage-2.git" | ||
}, | ||
"devDependencies": { | ||
"grunt": "~0.4.5", | ||
"@babel/core": "^7.0.0-beta.51", | ||
"@babel/preset-env": "^7.0.0-beta.51", | ||
"babel-cli": "^7.0.0-beta.3", | ||
"babel-preset-env": "^1.7.0", | ||
"browser-sync": "^2.24.5", | ||
"del": "^3.0.0", | ||
"grunt": "^1.0.3", | ||
"grunt-contrib-clean": "~0.6.0", | ||
"grunt-contrib-copy": "~0.8.0", | ||
"grunt-contrib-jshint": "~0.10.0", | ||
"grunt-contrib-nodeunit": "~0.4.1", | ||
"grunt-contrib-uglify": "~0.5.0", | ||
"grunt-mkdir": "~0.1.2", | ||
"grunt-resize-crop": "0.0.1" | ||
"grunt-resize-crop": "0.0.1", | ||
"gulp": "^3.9.1", | ||
"gulp-babel": "^8.0.0-beta.2", | ||
"gulp-concat": "^2.6.1", | ||
"gulp-grunt": "^0.5.5", | ||
"gulp-sourcemaps": "^2.6.4", | ||
"gulp-uglify": "^3.0.0", | ||
"gulp-useref": "^3.1.5", | ||
"gulp-util": "^3.0.8", | ||
"webpack": "^4.13.0", | ||
"webpack-cli": "^3.0.8", | ||
"webpack-dev-server": "^3.1.4", | ||
"webpack-stream": "^4.0.3" | ||
}, | ||
"dependencies": { | ||
"grunt-responsive-images": "^0.1.6" | ||
"grunt-responsive-images": "^0.1.6", | ||
"idb": "^2.1.3" | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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
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
Empty file.
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
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
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
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