Skip to content

Commit

Permalink
Merge pull request #162 from patronage/160-js
Browse files Browse the repository at this point in the history
160 js deps update
  • Loading branch information
ccorda authored Jan 13, 2023
2 parents 90f509b + 11b325b commit 9d029a2
Show file tree
Hide file tree
Showing 9 changed files with 1,793 additions and 1,779 deletions.
6 changes: 2 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"presets": [
"@babel/preset-env"
]
}
"presets": ["@babel/preset-env"]
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16
18
1 change: 1 addition & 0 deletions _build/.deploy_include.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
wp-content/themes/timber/dist/*
wp-content/themes/timber/static/*
wp-content/plugins/*
48 changes: 33 additions & 15 deletions gulpfile.babel.js → gulpfile.mjs
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
'use strict';

// load gulp and gulp plugins
import gulp from 'gulp';
import plugins from 'gulp-load-plugins';
import dartSass from 'sass';
import path from 'path';
import gulpSass from 'gulp-sass';
import revAll from 'gulp-rev-all';
const sass = gulpSass(dartSass);

const $ = plugins({
postRequireTransforms: {
sass: function (sass) {
return sass(require('sass'));
},
},
config: path.join(process.cwd(), 'package.json'),
});

// load node modules
import del from 'del';
import { deleteSync } from 'del';
import pump from 'pump';
import beeper from 'beeper';
import { argv } from 'yargs';

import yargs from 'yargs';
const argv = yargs.argv;

// others
import browserSync from 'browser-sync';
Expand Down Expand Up @@ -111,7 +113,7 @@ const styles = (done) => {
gulp.src(config.assets + '/scss/*.scss', {
sourcemaps: !isProduction,
}),
$.sass(sassOptions),
sass(sassOptions),
$.if(isProduction, $.autoprefixer('last 2 versions')),
$.if(isProduction, $.csso()),
gulp.dest(config.output + '/css', { sourcemaps: !isProduction }),
Expand Down Expand Up @@ -151,7 +153,7 @@ const scripts = (done) => {
[
gulp.src(config.theme + '/views/layout.twig'),
assets,
$.debug({ title: 'debug: ', showFiles: argv.debug }), //to debug files getting proccessed
$.debug({ title: 'debug: ', showFiles: argv?.debug }), // to debug files getting proccessed
$.filter(['**', '!**/layout.twig'], { restore: true }),
f,
$.jshint(),
Expand All @@ -178,7 +180,7 @@ const scripts = (done) => {

// When scripts runs, it creates extra files in copying from vendor we can delete
const cleanScripts = (done) => {
del.sync([config.output + '/wp-content']);
deleteSync([config.output + '/wp-content']);
done();
};

Expand All @@ -198,12 +200,28 @@ const copy = (done) => {

// loops through the generated html and replaces all references to static versions
const rev = (done) => {
let extensions = [
'.html',
'.css',
'.js',
'.png',
'.jpg',
'.jpeg',
'.gif',
'.svg',
'.woff',
'.woff2',
'.ttf',
'.eot',
'.otf',
];

pump(
[
gulp.src(config.dist + '/{css,js,fonts,img}/**/*'),
$.revAll.revision({ dontSearchFile: ['.js'] }),
revAll.revision({ dontSearchFile: ['.js'], includeFilesInManifest: extensions }),
gulp.dest(config.static),
$.revAll.manifestFile(),
revAll.manifestFile(),
gulp.dest(config.static),
],
(err) => {
Expand All @@ -219,7 +237,7 @@ const rev = (done) => {

// clean output directory
export const clean = (done) => {
del.sync([config.dev, config.static, config.dist]);
deleteSync([config.dev, config.static, config.dist]);
done();
};

Expand Down
53 changes: 27 additions & 26 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,49 @@
},
"dependencies": {
"autotrack": "2.4.1",
"bootstrap": "5.2.1",
"bootstrap": "5.2.3",
"fitvids.js": "davatron5000/fitvids.js#^1.2.0",
"jquery": "3.6.1",
"jquery": "3.6.3",
"jquery-match-height": "0.7.2",
"popper.js": "1.16.1"
},
"devDependencies": {
"@babel/core": "7.9.6",
"@babel/preset-env": "7.9.6",
"@babel/register": "7.9.0",
"@prettier/plugin-php": "0.18.7",
"beeper": "2.0.0",
"browser-sync": "2.26.13",
"del": "6.0.0",
"@prettier/plugin-php": "0.19.2",
"@babel/core": "7.20.12",
"@babel/preset-env": "7.20.2",
"@babel/register": "7.18.9",
"beeper": "3.0.0",
"browser-sync": "2.27.11",
"del": "7.0.0",
"gulp": "4.0.2",
"gulp-autoprefixer": "7.0.1",
"gulp-cli": "2.3.0",
"gulp-autoprefixer": "8.0.0",
"gulp-babel": "8.0.0",
"gulp-csso": "4.0.1",
"gulp-debug": "4.0.0",
"gulp-filter": "6.0.0",
"gulp-filter": "7.0.0",
"gulp-if": "3.0.0",
"gulp-jshint": "2.1.0",
"gulp-load-plugins": "2.0.4",
"gulp-load-plugins": "2.0.8",
"gulp-newer": "1.4.0",
"gulp-notify": "3.2.0",
"gulp-notify": "4.0.0",
"gulp-rename": "2.0.0",
"gulp-rev-all": "2.0.3",
"gulp-sass": "5.0.0",
"gulp-rev-all": "4.0.0",
"gulp-sass": "5.1.0",
"gulp-uglify": "3.0.2",
"gulp-useref": "4.0.1",
"husky": "0.14.3",
"jshint": "2.12.0",
"gulp-useref": "5.0.0",
"husky": "8.0.3",
"jshint": "2.13.6",
"jshint-stylish": "2.2.1",
"postcss": "8.4.14",
"prettier": "2.7.1",
"sass": "1.54.9",
"stylelint": "14.12.1",
"stylelint-config-idiomatic-order": "8.1.0",
"stylelint-config-prettier": "9.0.3",
"stylelint-config-standard-scss": "5.0.0",
"postcss": "8.4.21",
"prettier": "2.8.2",
"sass": "1.57.1",
"stylelint": "14.16.1",
"stylelint-config-idiomatic-order": "9.0.0",
"stylelint-config-prettier": "9.0.4",
"stylelint-config-standard-scss": "6.1.0",
"stylelint-prettier": "2.0.0",
"stylelint-scss": "4.3.0",
"yargs": "15.3.1"
"yargs": "17.6.2"
}
}
5 changes: 4 additions & 1 deletion wp-content/themes/timber/functions.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

// Make composer installed php libraries available
require_once get_theme_root() . '/../plugins/composer-libs/autoload.php';
$autoload_path = get_theme_root() . '/../plugins/composer-libs/autoload.php';
if (file_exists($autoload_path)) {
require_once $autoload_path;
}

//
// Load WP Config files
Expand Down
28 changes: 15 additions & 13 deletions wp-content/themes/timber/setup/helpers/rev.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ function rev($file, $domain = null) {
$dev = 'dev';
$assets = 'assets';
$manifest = 'rev-manifest.json';
$jsondata = @file_get_contents(
get_stylesheet_directory() . '/' . $static . '/' . $manifest,
);
$file_path = get_stylesheet_directory() . '/' . $static . '/' . $manifest;
if (file_exists($file_path)) {
$jsondata = @file_get_contents($file_path);
} else {
$jsondata = false;
}

if (defined('WP_ENV')) {
$env = WP_ENV;
Expand Down Expand Up @@ -47,22 +50,21 @@ function rev($file, $domain = null) {
// first check exact folder
$rev_check = isset($json[$file]);
if ($rev_check) {
$file_check = file_exists(
get_stylesheet_directory() . '/static/' . $json[$file],
);
$file_check = @file_exists(get_stylesheet_directory() . '/static/' . $json[$file]);
}

if ($rev_check && $file_check) {
$url = $theme . '/' . $static . '/' . $json[$file];
} else {
// js gets flattened, check there as well
$file = 'js/' . basename($file);
$file_check = file_exists(
get_stylesheet_directory() . '/static/' . $json[$file],
);
if ($file_check) {
$url = $theme . '/' . $static . '/' . $json[$file];
$jsfile = 'js/' . basename($file);
if (array_key_exists($jsfile, (array) $json)) {
$file_check = @file_exists(get_stylesheet_directory() . '/static/' . $json[$jsfile]);
if ($file_check) {
$url = $theme . '/' . $static . '/' . $json[$jsfile];
}
} else {
// return the original file
$url = $theme . '/' . $folder . '/' . $file;
}
}
Expand Down Expand Up @@ -119,4 +121,4 @@ function revBlock($files, $domain = null) {
return $html;
}

?>
?>
10 changes: 6 additions & 4 deletions wp-content/themes/timber/views/layout.twig
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
{% endif %}

<!-- parse-ignore-start -->
{#
- Load JS libs then custom scripts. Paths should be relative to assets folder
- Build block uses gulp-useref to copy/rev assets
- Rev function uses a custom php helper that adjusts filesname depending on env, and adds md5 hash in production
#}
- Load JS libs then custom scripts. Paths should be relative to assets folder
- Build block uses gulp-useref to copy/rev assets
- Rev function uses a custom php helper that adjusts filesname depending on env, and adds md5 hash in production
#}
<!-- parse-ignore-end -->

{% set rev_js %}
<!-- build:js js/all.js -->
Expand Down
Loading

0 comments on commit 9d029a2

Please sign in to comment.