Skip to content

Commit

Permalink
Added gulp-rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Thunder committed Jul 13, 2020
1 parent b2e9e77 commit ac273af
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 107 deletions.
26 changes: 19 additions & 7 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const autoprefixer = require('autoprefixer'); // - Adds vendor prefixes to CSS
const browserSync = require('browser-sync').create(); // - Live reload across
const browserSync = require('browser-sync').create(); // - Browser reload
const cache = require('gulp-cache');// - File based caching
const concat = require('gulp-concat'); // - Merges JS files
const cssnano = require('cssnano'); // - Minifies CSS
Expand All @@ -11,6 +11,7 @@ const modernizr = require('gulp-modernizr'); // detects features in browser.
const notify = require('gulp-notify'); // - Notifys messages in the terminal
const path = require('path'); // - Gets Path for gulp-notify
const postcss = require('gulp-postcss'); // -
const rename = require('gulp-rename'); // Adds .min to filename
const sass = require('gulp-sass'); // - Transforms Sass into CSS
const sourcemaps = require('gulp-sourcemaps'); // - Creates sourcemaps
const { src, series, parallel, dest, } = require('gulp');
Expand Down Expand Up @@ -44,7 +45,7 @@ function cssTask(){
cssnano( ({
preset: [
'default', {
// Change if you do not which to minify
// Change if you do not which to minify
normalizeWhitespace: true,
discardComments: true,
}],
Expand All @@ -53,7 +54,12 @@ function cssTask(){
))
// Now add/write the sourcemaps
.pipe(sourcemaps.write('.'))
// Save compiled css to dist folder

// Add .min to filename
.pipe(rename({
extname: '.min.css'
}))
// Save compiled css to dist folder
.pipe(gulp.dest('./dist/css'))
// Stream changes to all browsers
.pipe(browserSync.stream());
Expand All @@ -80,10 +86,12 @@ function jsTask(){
))
// Add/write the sourcemaps
.pipe(sourcemaps.write('.'))
// Rename to add .min to filename
.pipe(rename({
extname: '.min.js'
}))
// Save compiled js to dist folder
.pipe(gulp.dest('./dist/js'))
// Notify the files copied in the terminal
.pipe(notify('Minified <%= file.relative %> to <%= file.path %>' ))
}
//=====================================================================
// Copy and minify HTML
Expand Down Expand Up @@ -123,7 +131,8 @@ function imageMin(done) {
plugins: [{cleanupIDs: false}]
})
],
{verbose: true }
// Shows files optimastion results in the terminal
{verbose: true }
)))
// Send optimised images to folder
.pipe(gulp.dest('./dist/assets/images')),
Expand All @@ -141,6 +150,7 @@ function modernizrTask () {
'setClasses',
"html5printshiv"
],
// Add browser tests
'tests': [
'touchevents',
'backgroundcliptext',
Expand Down Expand Up @@ -178,6 +188,7 @@ function copyVideo (done) {
})),
done();
}

// Copy fonts to dist folder
function copyFonts (done) {
// Locate files
Expand All @@ -192,6 +203,7 @@ function copyFonts (done) {
})),
done();
}

// Copy Favicon to dist folder
function copyFavicon (done) {
// Locate files that do not need to be compressed or altered
Expand Down Expand Up @@ -220,6 +232,7 @@ function watchTask() {
logConnections: true,
logPrefix: "Scaffold II",
notify: true,
// Syncs across multiple browsers
ghostMode: {
scroll: true,
links: true,
Expand Down Expand Up @@ -251,7 +264,6 @@ function watchTask() {
function clean() {
// Del allows deletetion of files and folders using globs
return del('./dist/*');

}

// Clear the image cache. Run 'gulp clear' in the terminal.
Expand Down
Loading

0 comments on commit ac273af

Please sign in to comment.