在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):S1SYPHOS/Gulp-Kirby-Starter-Kit开源软件地址(OpenSource Url):https://github.com/S1SYPHOS/Gulp-Kirby-Starter-Kit开源编程语言(OpenSource Language):PHP 98.1%开源软件介绍(OpenSource Introduction):Gulp/Kirby StarterKitYou heard about Kirby and want to use it on your next project? You want to harness the power of Gulp? Then THIS is for you! Here's my personal (thus opinionated) Gulp+Kirby boilerplate, starring:
Although it's good practice to set up an environment closely resembling your production server (eg Vagrant, Docker, MAMP / XAMPP or Valet), feel free to use PHP's built-in development server or have a quick glance with Psst! Need the Kirby 2 version? Over here. FeaturesThis boilerplate provides a solid starting point that you can build upon: Workflow:
Table of Contents Requirements
In order to keep everything neat, each task resides in its own file under Pre-installed Kirby plugins:
Getting startedMake sure Node.js is installed on your system, then clone this repository and install its dependencies via NPM:
Now just type ConfigurationTweaking the asset pipeline is pretty easy, as Development serverBy default, this boilerplate uses PHP's built-in server. If you are using a local development server (as recommended above), just set Linting styles & scriptsRules for linting styles and scripts are excluded from this pattern and located in I prefer linting my files while editing them, which is supported by all major text editors such as GitHub's Atom, Microsoft's Visual Studio Code, Sublime Text (and even Adobe's Brackets) through plugins). There are several ways to load the configuration object for both stylelint and ESLint. As for now, they reside inside Cache-busting / FingerprintingFor cache busting via Kirby's built-in helper functions ApacheIf you're using Apache as your webserver and you are using a custom
NGINXIf you're using NGINX as your webserver, add the following lines to your virtual host setup:
Critical CSSA critical CSS approach can be achieved by simply replacing this PHP snippet .. if (option('environment', 'development') === 'production') {
echo Bnomei\Fingerprint::css('/assets/styles/main.min.css', ['integrity' => true]);
} else {
echo css('assets/styles/main.css');
} .. with this one: if (option('environment', 'development') === 'production') {
// Critical
$criticalPath = '/assets/styles/critical.css';
$critical = (new Asset($kirby->root('assets') . $criticalPath))->read();
echo '<style>' . $critical . '</style>';
// Non-Critical
$cssPath = '/assets/styles/main.min.css';
echo Bnomei\Fingerprint::css($cssPath, [
'integrity' => true,
'media' => 'print',
'onload' => 'this.media="all"',
]);
echo '<noscript>' . Bnomei\Fingerprint::css($cssPath, ['integrity' => true]) . '</noscript>';
} else {
echo css('assets/styles/main.css');
} When running Note: If you are using CSP headers, see this issue for more information. Favicon generationAfter generating favicons, insert this in your <!-- Favicons -->
<link rel="shortcut icon" href="<?= url('favicon.ico') ?>">
<?php snippet('favicons') ?> Self-hosting fontsIf you already have font files (or at least one), that's great. Otherwise, there's FontSquirrel's webfont generator (including subsetting, file conversion, CSS generation and much more). If Google Fonts are what you want, then this might be helpful. After learning about webfont strategies, you might want to subset your fonts, but rather than doing it manually (uploading, configuring, downloading, ..), let the machine handle it for you: This boilerplate supports font subsetting via
Preloading fontsThis goes beautifully with preloading - simply insert this in your <!-- Fonts -->
<link rel="preload" href="/assets/fonts/my-font.subset.woff2" as="font" type="font/woff2" crossorigin> IconsFor modern SVG icons, there are great sources out there, such as:
WIP Note: Before publishing your project, be sure to check your Special ThanksI'd like to thank everybody that's making great software - you people are awesome. Also I'm always thankful for feedback and bug reports :) |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论