-
Notifications
You must be signed in to change notification settings - Fork 1
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 #1 from J0ddy/update-1.1.0
Update 1.1.0
- Loading branch information
Showing
7 changed files
with
244 additions
and
170 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 |
---|---|---|
@@ -1,69 +1,79 @@ | ||
const gulp = require('gulp'); | ||
const sass = require('gulp-sass')(require('sass')); | ||
const autoprefixer = require('gulp-autoprefixer'); | ||
const browserSync = require('browser-sync').create(); | ||
const webpack = require('webpack-stream'); | ||
const webpackConfig = require('./webpack.config.js'); | ||
const htmlmin = require('gulp-htmlmin'); | ||
import gulp from 'gulp'; | ||
import sass from 'gulp-dart-sass'; | ||
import autoprefixer from 'gulp-autoprefixer'; | ||
import browserSync from 'browser-sync'; | ||
import webpack from 'webpack-stream'; | ||
import webpackConfig from './webpack.config.js'; | ||
import htmlmin from 'gulp-htmlmin'; | ||
import imagemin from 'gulp-imagemin'; | ||
import changed from 'gulp-changed'; | ||
import fetch from 'node-fetch'; | ||
|
||
// Webpack task | ||
gulp.task('webpack', function() { | ||
return gulp.src('src/js/*.js') | ||
gulp.task('webpack', () => | ||
gulp.src('src/js/*.js') | ||
.pipe(webpack(webpackConfig)) | ||
.pipe(gulp.dest('dist/js')) | ||
.pipe(browserSync.stream()); | ||
}); | ||
.pipe(browserSync.stream()) | ||
); | ||
|
||
// Sass task | ||
gulp.task('sass', function() { | ||
return gulp.src('src/scss/*.scss') | ||
.pipe(sass().on('error', sass.logError)) | ||
.pipe(autoprefixer()) | ||
.pipe(gulp.dest('dist/css')) | ||
.pipe(browserSync.stream()); | ||
}); | ||
gulp.task('sass', () => | ||
gulp.src('src/scss/*.scss') | ||
.pipe(sass().on('error', sass.logError)) | ||
.pipe(autoprefixer()) | ||
.pipe(gulp.dest('dist/css')) | ||
.pipe(browserSync.stream()) | ||
); | ||
|
||
// Html task | ||
gulp.task('html', function() { | ||
return gulp.src('src/html/*.html') | ||
gulp.task('html', () => | ||
gulp.src('src/html/*.html') | ||
.pipe(htmlmin({ collapseWhitespace: true })) | ||
.pipe(gulp.dest('dist')) | ||
.pipe(browserSync.stream()); | ||
}); | ||
|
||
.pipe(browserSync.stream()) | ||
); | ||
|
||
// Images task | ||
gulp.task('images', () => | ||
gulp.src('src/img/**/*.{jpg,jpeg,png,gif,svg}') | ||
.pipe(changed('dist/img')) | ||
.pipe(imagemin()) | ||
.pipe(gulp.dest('dist/img')) | ||
.pipe(browserSync.stream()) | ||
); | ||
|
||
// Watch task | ||
gulp.task('watch', function() { | ||
browserSync.init({ | ||
server: { | ||
baseDir: './dist', | ||
index: 'index.html', | ||
middleware: [ | ||
function(req, res, next) { | ||
if (/\.js$/.test(req.url)) { | ||
res.setHeader('Content-Type', 'application/javascript'); | ||
} else if (/\.css$/.test(req.url)) { | ||
res.setHeader('Content-Type', 'text/css'); | ||
} | ||
next(); | ||
} | ||
], | ||
open: false | ||
gulp.task('watch', () => { | ||
browserSync.init({ | ||
server: { | ||
baseDir: './dist', | ||
index: 'index.html', | ||
middleware: [ | ||
function(req, res, next) { | ||
if (/\.js$/.test(req.url)) { | ||
res.setHeader('Content-Type', 'application/javascript'); | ||
} else if (/\.css$/.test(req.url)) { | ||
res.setHeader('Content-Type', 'text/css'); | ||
} | ||
next(); | ||
} | ||
}); | ||
], | ||
open: false | ||
} | ||
}); | ||
|
||
gulp.watch('src/scss/*.scss', gulp.series('sass')); | ||
gulp.watch('src/js/*.js', gulp.series('webpack')); | ||
gulp.watch('src/html/*.html', gulp.series('html')); | ||
gulp.watch('.env', gulp.series('webpack')); | ||
//gulp.watch('dist/*.html').on('change', browserSync.reload); | ||
}); | ||
|
||
|
||
// Dev task | ||
gulp.task('dev', gulp.series('sass', 'webpack', 'html', 'watch')); | ||
gulp.task('dev', gulp.series('sass', 'webpack', 'html', 'images', 'watch')); | ||
|
||
// Build task | ||
gulp.task('build', gulp.series('sass', 'webpack', 'html')); | ||
gulp.task('build', gulp.series('sass', 'webpack', 'html', 'images')); | ||
|
||
// Default task | ||
gulp.task('default', gulp.series('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
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
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.