Skip to content

Commit

Permalink
📦 NEW: Zip task
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadawais committed Oct 25, 2020
1 parent 7a6641f commit a8fed53
Show file tree
Hide file tree
Showing 15 changed files with 632 additions and 269 deletions.
4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

21 changes: 0 additions & 21 deletions .eslintrc.js

This file was deleted.

10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"singleQuote": true,
"printWidth": 120,
"useTabs": true,
"tabWidth": 4,
"semi": true
}
9 changes: 7 additions & 2 deletions WPGulp/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ module.exports = {
sourceType: 'module'
},
rules: {
// Disable weird WP spacing rules.
// 'space-before-function-paren': 'off',
// 'space-in-parens': 'off',
// 'array-bracket-spacing': 'off', // Disable weird WP spacing rules.
indent: ['error', 'tab'],
'linebreak-style': ['error', 'unix'],
semi: ['error', 'always'],
quotes: ['error', 'single'],
semi: ['error', 'always']
'linebreak-style': ['error', 'unix']
}
};
``;
86 changes: 58 additions & 28 deletions WPGulp/gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const reload = done => {
*/
gulp.task('styles', () => {
return gulp
.src(config.styleSRC, { allowEmpty: true })
.src(config.styleSRC, {allowEmpty: true})
.pipe(plumber(errorHandler))
.pipe(sourcemaps.init())
.pipe(
Expand All @@ -125,22 +125,27 @@ gulp.task('styles', () => {
})
)
.on('error', sass.logError)
.pipe(sourcemaps.write({ includeContent: false }))
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write({includeContent: false}))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(autoprefixer(config.BROWSERS_LIST))
.pipe(sourcemaps.write('./'))
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.styleDestination))
.pipe(filter('**/*.css')) // Filtering stream to only css files.
.pipe(mmq({ log: true })) // Merge Media Queries only for .min.css version.
.pipe(mmq({log: true})) // Merge Media Queries only for .min.css version.
.pipe(browserSync.stream()) // Reloads style.css if that is enqueued.
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss({ maxLineLen: 10 }))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss({maxLineLen: 10}))
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.styleDestination))
.pipe(filter('**/*.css')) // Filtering stream to only css files.
.pipe(browserSync.stream()) // Reloads style.min.css if that is enqueued.
.pipe(notify({ message: '\n\n✅ ===> STYLES — completed!\n', onLast: true }));
.pipe(
notify({
message: '\n\n✅ ===> STYLES — completed!\n',
onLast: true
})
);
});

/**
Expand All @@ -160,7 +165,7 @@ gulp.task('styles', () => {
*/
gulp.task('stylesRTL', () => {
return gulp
.src(config.styleSRC, { allowEmpty: true })
.src(config.styleSRC, {allowEmpty: true})
.pipe(plumber(errorHandler))
.pipe(sourcemaps.init())
.pipe(
Expand All @@ -171,24 +176,29 @@ gulp.task('stylesRTL', () => {
})
)
.on('error', sass.logError)
.pipe(sourcemaps.write({ includeContent: false }))
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write({includeContent: false}))
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(autoprefixer(config.BROWSERS_LIST))
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(rename({ suffix: '-rtl' })) // Append "-rtl" to the filename.
.pipe(rename({suffix: '-rtl'})) // Append "-rtl" to the filename.
.pipe(rtlcss()) // Convert to RTL.
.pipe(sourcemaps.write('./')) // Output sourcemap for style-rtl.css.
.pipe(gulp.dest(config.styleDestination))
.pipe(filter('**/*.css')) // Filtering stream to only css files.
.pipe(browserSync.stream()) // Reloads style.css or style-rtl.css, if that is enqueued.
.pipe(mmq({ log: true })) // Merge Media Queries only for .min.css version.
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss({ maxLineLen: 10 }))
.pipe(mmq({log: true})) // Merge Media Queries only for .min.css version.
.pipe(rename({suffix: '.min'}))
.pipe(minifycss({maxLineLen: 10}))
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.styleDestination))
.pipe(filter('**/*.css')) // Filtering stream to only css files.
.pipe(browserSync.stream()) // Reloads style.css or style-rtl.css, if that is enqueued.
.pipe(notify({ message: '\n\n✅ ===> STYLES RTL — completed!\n', onLast: true }));
.pipe(
notify({
message: '\n\n✅ ===> STYLES RTL — completed!\n',
onLast: true
})
);
});

/**
Expand All @@ -204,15 +214,15 @@ gulp.task('stylesRTL', () => {
*/
gulp.task('vendorsJS', () => {
return gulp
.src(config.jsVendorSRC, { since: gulp.lastRun('vendorsJS') }) // Only run on changed files.
.src(config.jsVendorSRC, {since: gulp.lastRun('vendorsJS')}) // Only run on changed files.
.pipe(plumber(errorHandler))
.pipe(
babel({
presets: [
[
'@babel/preset-env', // Preset to compile your modern JS to ES5.
{
targets: { browsers: config.BROWSERS_LIST } // Target browser list to support.
targets: {browsers: config.BROWSERS_LIST} // Target browser list to support.
}
]
]
Expand All @@ -231,7 +241,12 @@ gulp.task('vendorsJS', () => {
.pipe(uglify())
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.jsVendorDestination))
.pipe(notify({ message: '\n\n✅ ===> VENDOR JS — completed!\n', onLast: true }));
.pipe(
notify({
message: '\n\n✅ ===> VENDOR JS — completed!\n',
onLast: true
})
);
});

/**
Expand All @@ -247,15 +262,15 @@ gulp.task('vendorsJS', () => {
*/
gulp.task('customJS', () => {
return gulp
.src(config.jsCustomSRC, { since: gulp.lastRun('customJS') }) // Only run on changed files.
.src(config.jsCustomSRC, {since: gulp.lastRun('customJS')}) // Only run on changed files.
.pipe(plumber(errorHandler))
.pipe(
babel({
presets: [
[
'@babel/preset-env', // Preset to compile your modern JS to ES5.
{
targets: { browsers: config.BROWSERS_LIST } // Target browser list to support.
targets: {browsers: config.BROWSERS_LIST} // Target browser list to support.
}
]
]
Expand All @@ -274,7 +289,12 @@ gulp.task('customJS', () => {
.pipe(uglify())
.pipe(lineec()) // Consistent Line Endings for non UNIX systems.
.pipe(gulp.dest(config.jsCustomDestination))
.pipe(notify({ message: '\n\n✅ ===> CUSTOM JS — completed!\n', onLast: true }));
.pipe(
notify({
message: '\n\n✅ ===> CUSTOM JS — completed!\n',
onLast: true
})
);
});

/**
Expand All @@ -299,17 +319,22 @@ gulp.task('images', () => {
.pipe(
cache(
imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.jpegtran({ progressive: true }),
imagemin.optipng({ optimizationLevel: 3 }), // 0-7 low-high.
imagemin.gifsicle({interlaced: true}),
imagemin.mozjpeg({quality: 90, progressive: true}),
imagemin.optipng({optimizationLevel: 3}), // 0-7 low-high.
imagemin.svgo({
plugins: [{ removeViewBox: true }, { cleanupIDs: false }]
plugins: [{removeViewBox: true}, {cleanupIDs: false}]
})
])
)
)
.pipe(gulp.dest(config.imgDST))
.pipe(notify({ message: '\n\n✅ ===> IMAGES — completed!\n', onLast: true }));
.pipe(
notify({
message: '\n\n✅ ===> IMAGES — completed!\n',
onLast: true
})
);
});

/**
Expand All @@ -318,7 +343,7 @@ gulp.task('images', () => {
* Deletes the images cache. By running the next "images" task,
* each image will be regenerated.
*/
gulp.task('clearCache', function(done) {
gulp.task('clearCache', function (done) {
return cache.clearAll(done);
});

Expand All @@ -345,7 +370,12 @@ gulp.task('translate', () => {
})
)
.pipe(gulp.dest(config.translationDestination + '/' + config.translationFile))
.pipe(notify({ message: '\n\n✅ ===> TRANSLATE — completed!\n', onLast: true }));
.pipe(
notify({
message: '\n\n✅ ===> TRANSLATE — completed!\n',
onLast: true
})
);
});

/**
Expand Down
15 changes: 9 additions & 6 deletions WPGulp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,36 @@
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/register": "^7.0.0",
"@babel/preset-env": "^7.12.1",
"beepbeep": "^1.2.2",
"browser-sync": "^2.11.1",
"eslint": "^5.5.0",
"eslint": "^7.12.0",
"eslint-config-wordpress": "^2.0.0",
"gulp": "^4.0.0",
"gulp-autoprefixer": "^6.0.0",
"gulp-autoprefixer": "^7.0.1",
"gulp-babel": "^8.0.0",
"gulp-cache": "^1.0.2",
"gulp-concat": "^2.5.2",
"gulp-filter": "^5.1.0",
"gulp-imagemin": "^4.1.0",
"gulp-filter": "^6.0.0",
"gulp-imagemin": "^7.1.0",
"gulp-line-ending-corrector": "^1.0.1",
"gulp-merge-media-queries": "^0.2.1",
"gulp-notify": "^3.0.0",
"gulp-plumber": "^1.2.0",
"gulp-remember": "^1.0.1",
"gulp-rename": "^1.2.0",
"gulp-rename": "^2.0.0",
"gulp-rtlcss": "^1.2.0",
"gulp-sass": "^4.0.1",
"gulp-sort": "^2.0.0",
"gulp-sourcemaps": "^2.6.2",
"gulp-uglify": "^3.0.0",
"gulp-uglifycss": "^1.0.6",
"gulp-wp-pot": "^2.0.7"
"gulp-wp-pot": "^2.0.7",
"gulp-zip": "^5.0.2"
},
"scripts": {
"start": "gulp",
"zip": "gulp zip",
"styles": "gulp styles",
"images": "gulp images",
"js-custom": "gulp customJS",
Expand Down
Loading

0 comments on commit a8fed53

Please sign in to comment.