This commit is contained in:
Jan Jastrow 2018-09-29 16:47:22 +02:00
parent 150b801f86
commit a6d13f5c28
4 changed files with 63 additions and 132 deletions

11
changelog.md Normal file
View File

@ -0,0 +1,11 @@
# Changelog
## 2.0.1 (2018-09-29)
- Replaced `del` package with `rimraf`
- Added `sanitize.css` as dependency
- Updated structure of gulpfile
## 2.0.0
- Rewritten most of the gulpfile and packacke.json

View File

@ -1,6 +1,5 @@
// Require npm-modules // Initiate npm-modules
var del = require('del'), var gulp = require('gulp'),
gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'), autoprefixer = require('gulp-autoprefixer'),
concat = require('gulp-concat'), concat = require('gulp-concat'),
cssnano = require('gulp-cssnano'), cssnano = require('gulp-cssnano'),
@ -9,43 +8,53 @@ var del = require('del'),
plumber = require('gulp-plumber'), plumber = require('gulp-plumber'),
rename = require('gulp-rename'), rename = require('gulp-rename'),
sass = require('gulp-sass'), sass = require('gulp-sass'),
merge2 = require('merge2'); merge2 = require('merge2'),
rimraf = require('rimraf');
var Config = { var Config = {
inputDir: '_source', inputDir: '_source/',
outputDir: '_dist' outputDir: '_dist/'
} }
var SassConfig = { var SassConfig = {
inputDir: '_source/sass/**/*.scss', inputDir: '_source/sass/',
outputDir: '_dist/css', outputDir: '_dist/css/',
options: { options: {
outputStyle: 'expanded' outputStyle: 'expanded'
}, },
autoprefixer: ['last 2 version', 'IE 11', 'Firefox ESR', 'ios 10', 'android 4.4'] autoprefixer: ['last 2 version', 'IE 11', 'Firefox ESR', 'ios 10', 'android 4.4']
} }
// Tasks //:: Tasks
// clean the folders // delete the output folder
gulp.task('clean', function(cb) { gulp.task('clean', function(cb) {
return del([Config.outputDir], cb) return rimraf(Config.outputDir, cb)
}); });
// render SASS // render SASS
gulp.task('sass', function() {var onError = function(err) { gulp.task('sass', function() {
notify.onError({ var onError = function(err) {
title: 'gulp', notify.onError({
subtitle: 'Error!', title: 'gulp',
message: '❌ <%= error.message %>', subtitle: 'Error!',
sound: 'Submarine' message: '❌ <%= error.message %>',
})(err); sound: 'Submarine'
})(err);
this.emit('end'); this.emit('end');
}; };
const sanitize = gulp.src('node_modules/sanitize.css/sanitize.css');
const scss = gulp.src(SassConfig.inputDir);
return merge2(sanitize, scss) return merge2(
gulp.src([
'node_modules/sanitize.css/sanitize.css'
]))
.pipe(concat('addons.css'))
.pipe(gulp.dest(SassConfig.outputDir))
.pipe(cssnano())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(SassConfig.outputDir)),
gulp.src(SassConfig.inputDir + '*.scss')
.pipe(concat('styles.css')) .pipe(concat('styles.css'))
.pipe(plumber({errorHandler: onError})) .pipe(plumber({errorHandler: onError}))
.pipe(sass(SassConfig.options).on('error', sass.logError)) .pipe(sass(SassConfig.options).on('error', sass.logError))
@ -58,39 +67,36 @@ gulp.task('sass', function() {var onError = function(err) {
.pipe(notify({ .pipe(notify({
title: 'gulp', title: 'gulp',
subtitle: 'Success!', subtitle: 'Success!',
message: 'SASS compiled', message: 'SASS compiled',
timeout: '2' timeout: '2'
})); }));
}); });
gulp.task('sass-only', function() { gulp.task('sass-only', function() {
return gulp return gulp
.src(SassConfig.inputDir) .src(SassConfig.inputDir + '*.scss')
.pipe(sass(SassConfig.options).on('error', sass.logError)) .pipe(sass(SassConfig.options).on('error', sass.logError))
.pipe(gulp.dest(SassConfig.outputDir)); .pipe(gulp.dest(SassConfig.outputDir));
}); });
// Copy those other files // Copy those other files
gulp.task('copy', function() { gulp.task('copy', function() {
gulp.src([Config.inputDir + '/*.*']) gulp.src([Config.inputDir + '*.*'])
.pipe(gulp.dest(Config.outputDir)) .pipe(gulp.dest(Config.outputDir))
.pipe(livereload()) .pipe(livereload())
gulp.src([Config.inputDir + '/inc/**/*']) gulp.src([Config.inputDir + 'inc/**/*'])
.pipe(gulp.dest(Config.outputDir + '/inc')) .pipe(gulp.dest(Config.outputDir + '/inc'))
.pipe(livereload()) .pipe(livereload())
gulp.src([Config.inputDir + '/js/**/*.*'])
.pipe(gulp.dest(Config.outputDir + '/js'))
.pipe(livereload())
}) })
gulp.task('watch', function() { gulp.task('watch', function() {
livereload.listen() livereload.listen()
// Watch .scss files // Watch .scss files
gulp.watch(SassConfig.inputDir, ['sass']); gulp.watch(SassConfig.inputDir + '*.scss', ['sass']);
// Watch php files // Watch php files
gulp.watch(Config.inputDir + '/*.php', ['copy']) gulp.watch(Config.inputDir + '*.php', ['copy'])
gulp.watch(Config.inputDir + '/inc/*.php', ['copy']); gulp.watch(Config.inputDir + 'inc/*.php', ['copy']);
}); });
// Default: First 'clean', then the rest // Default: First 'clean', then the rest

94
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "Website_Template", "name": "Website_Template",
"version": "2.0.0", "version": "2.0.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -193,15 +193,6 @@
"integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==", "integrity": "sha512-B1qMD3RBP7O8o0H2KbrXDyB0IccejMF15+87Lvlor12ONPRHP6gTjXMNkt/d3ZuOGbAe66hFmaCfECI24Ufp6w==",
"dev": true "dev": true
}, },
"array-union": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz",
"integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=",
"dev": true,
"requires": {
"array-uniq": "^1.0.1"
}
},
"array-uniq": { "array-uniq": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz",
@ -1048,20 +1039,6 @@
"integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=", "integrity": "sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=",
"dev": true "dev": true
}, },
"del": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/del/-/del-3.0.0.tgz",
"integrity": "sha1-U+z2mf/LyzljdpGrE7rxYIGXZuU=",
"dev": true,
"requires": {
"globby": "^6.1.0",
"is-path-cwd": "^1.0.0",
"is-path-in-cwd": "^1.0.0",
"p-map": "^1.1.1",
"pify": "^3.0.0",
"rimraf": "^2.2.8"
}
},
"delayed-stream": { "delayed-stream": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
@ -1688,27 +1665,6 @@
"which": "^1.2.14" "which": "^1.2.14"
} }
}, },
"globby": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz",
"integrity": "sha1-9abXDoOV4hyFj7BInWTfAkJNUGw=",
"dev": true,
"requires": {
"array-union": "^1.0.1",
"glob": "^7.0.3",
"object-assign": "^4.0.1",
"pify": "^2.0.0",
"pinkie-promise": "^2.0.0"
},
"dependencies": {
"pify": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz",
"integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=",
"dev": true
}
}
},
"globule": { "globule": {
"version": "0.1.0", "version": "0.1.0",
"resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz", "resolved": "https://registry.npmjs.org/globule/-/globule-0.1.0.tgz",
@ -2561,30 +2517,6 @@
} }
} }
}, },
"is-path-cwd": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz",
"integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=",
"dev": true
},
"is-path-in-cwd": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz",
"integrity": "sha512-FjV1RTW48E7CWM7eE/J2NJvAEEVektecDBVBE5Hh3nM1Jd0kvhHtX68Pr3xsDf857xt3Y4AkwVULK1Vku62aaQ==",
"dev": true,
"requires": {
"is-path-inside": "^1.0.0"
}
},
"is-path-inside": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz",
"integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=",
"dev": true,
"requires": {
"path-is-inside": "^1.0.1"
}
},
"is-plain-obj": { "is-plain-obj": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
@ -3555,12 +3487,6 @@
"os-tmpdir": "^1.0.0" "os-tmpdir": "^1.0.0"
} }
}, },
"p-map": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz",
"integrity": "sha512-r6zKACMNhjPJMTl8KcFH4li//gkrXWfbD6feV8l6doRHlzljFWGJ2AP6iKaCJXyZmAUMOPtvbW7EXkbWO/pLEA==",
"dev": true
},
"parse-filepath": { "parse-filepath": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz", "resolved": "https://registry.npmjs.org/parse-filepath/-/parse-filepath-1.0.2.tgz",
@ -3614,12 +3540,6 @@
"integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
"dev": true "dev": true
}, },
"path-is-inside": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz",
"integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=",
"dev": true
},
"path-parse": { "path-parse": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
@ -3681,12 +3601,6 @@
"integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=", "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=",
"dev": true "dev": true
}, },
"pify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
"integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=",
"dev": true
},
"pinkie": { "pinkie": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz",
@ -5098,9 +5012,9 @@
"dev": true "dev": true
}, },
"sanitize.css": { "sanitize.css": {
"version": "7.0.0", "version": "7.0.3",
"resolved": "https://registry.npmjs.org/sanitize.css/-/sanitize.css-7.0.0.tgz", "resolved": "https://registry.npmjs.org/sanitize.css/-/sanitize.css-7.0.3.tgz",
"integrity": "sha512-TAUJPwX1lQJ8zGD4k/1Boj58y1P2SFLL0CeeUTjsxW2QueGcmi8c0XSlfY/LZrdV777cfZkLPE23FOzlWSejNA==", "integrity": "sha512-jV5ON1hb1vYixnWu7FOboBhYNowww+YYM04gOS2vGaXUmXciJ3YKVjZcnRo74R8OFjSySaXRJjzkjcl1emr1oA==",
"dev": true "dev": true
}, },
"sass-graph": { "sass-graph": {

View File

@ -1,7 +1,7 @@
{ {
"name": "Website_Template", "name": "Website_Template",
"description": "npm & gulp development template", "description": "npm & gulp development template",
"version": "2.0.0", "version": "2.0.1",
"author": "Jan Jastrow", "author": "Jan Jastrow",
"license": "MIT", "license": "MIT",
"homepage": "https://jan.jastrow.me", "homepage": "https://jan.jastrow.me",
@ -17,7 +17,6 @@
}, },
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"del": "^3.0.0",
"gulp": "^3.9.1", "gulp": "^3.9.1",
"gulp-autoprefixer": "^5.0.0", "gulp-autoprefixer": "^5.0.0",
"gulp-concat": "^2.6.1", "gulp-concat": "^2.6.1",
@ -28,6 +27,7 @@
"gulp-rename": "^1.4.0", "gulp-rename": "^1.4.0",
"gulp-sass": "^4.0.1", "gulp-sass": "^4.0.1",
"merge2": "^1.2.2", "merge2": "^1.2.2",
"sanitize.css": "^7.0.0" "rimraf": "^2.6.2",
"sanitize.css": "^7.0.3"
} }
} }