Skip to content

Commit

Permalink
Fixed asset rev and added Imager config
Browse files Browse the repository at this point in the history
  • Loading branch information
bymayo committed Nov 2, 2018
1 parent a2d221b commit b4b3a42
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 31 deletions.
28 changes: 7 additions & 21 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
# The environment Craft is currently running in ('dev', 'staging', 'production', etc.)
ENVIRONMENT="dev"

# The secure key Craft will use for hashing and encrypting data
SECURITY_KEY=""

# The database driver that will used ('mysql' or 'pgsql')
DB_DRIVER="mysql"

# The database server name or IP address (usually this is 'localhost' or '127.0.0.1')
DB_SERVER="localhost"

# The database username to connect with
DB_USER="root"

# The database password to connect with
DB_PASSWORD=""

# The name of the database to select
DB_USER=""
DB_PASSWORD="$9u"
DB_DATABASE=""

# The database schema that will be used (PostgreSQL only)
DB_DRIVER="mysql"
DB_SERVER="localhost"
DB_SCHEMA="public"

# The prefix that should be added to generated table names (only necessary if multiple things are sharing the same database)
DB_TABLE_PREFIX=""
DB_PORT="3306"

# The port to connect to the database with. Will default to 5432 for PostgreSQL and 3306 for MySQL.
DB_PORT=""
ASSETS_URL="http://website.dev/uploads"
ASSETS_PATH="/path/to/uploads"
11 changes: 8 additions & 3 deletions config/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
// Cache
'enableTemplateCaching' => true,
'cacheMethod' => 'file',
'cacheDuration' => 86400, // 24 Hours
'cacheDuration' => 0, // 86400 = 24 Hours
'cacheElementQueries' => false,
// Images / Files
'defaultImageQuality' => '100',
'extraAllowedFileExtensions' => 'ico,xml,json',
Expand All @@ -32,8 +33,12 @@
'enableCsrfProtection' => true,
'allowUpdates' => false,
'backupOnUpdate' => true,
'errorTemplatePrefix' => '_'

'errorTemplatePrefix' => '_',
// Aliases
'aliases' => [
'@assetBaseUrl' => getenv('ASSETS_URL'),
'@assetBasePath' => getenv('ASSETS_PATH')
]
],
'dev' => [
'siteUrl' => null,
Expand Down
53 changes: 49 additions & 4 deletions config/imager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,54 @@

return [
'*' => [
'imagerUrl' => getenv('ASSETS_URL') . '/imager',
'imagerSystemPath' => getenv('ASSETS_PATH') . '/imager',
'cacheEnabled' => true,
'cacheDuration' => 31536000, // 1 year
'cacheDurationRemoteFiles' => 31536000, // 1 year
'jpegQuality' => 100,
'pngCompressionLevel' => 0,
'resizeFilter' => 'lanczos',
'hashPath' => true,
'optimizeType' => 'job',
'optimizers' => ['jpegoptim', 'jpegtran', 'optipng', 'gifsicle'],
'optimizerConfig' => [
'jpegoptim' => [
'extensions' => ['jpg'],
'path' => '/usr/bin/jpegoptim',
'optionString' => '--strip-all -m85 -o -p'
],
'jpegtran' => [
'extensions' => ['jpg'],
'path' => '/usr/bin/jpegtran',
'optionString' => '-optimize -copy none'
],
'mozjpeg' => [
'extensions' => ['jpg'],
'path' => '/usr/bin/mozjpeg',
'optionString' => '-optimize -copy none'
],
'optipng' => [
'extensions' => ['png'],
'path' => '/usr/bin/optipng',
'optionString' => '-preserve -strip all'
],
'pngquant' => [
'extensions' => ['png'],
'path' => '/usr/bin/pngquant',
'optionString' => '--strip --skip-if-larger --quality=80-85 --speed 1'
],
'gifsicle' => [
'extensions' => ['gif'],
'path' => '/usr/bin/gifsicle',
'optionString' => '--optimize=3 --colors 256'
]
]
],
'dev' => [
'noop' => true,
'suppressExceptions' => true
]
'dev' => [
'optimizers' => null,
'noop' => true,
'suppressExceptions' => true,
'skipExecutableExistCheck' => true
]
];
7 changes: 4 additions & 3 deletions templates/_layout/base.twig
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
{# Inline / Critical CSS #}
{% if
block('inlineCss')|length or
block('criticalCss')|length
block('criticalCss')|length and
not craft.config.devMode
%}
<style>
{% block criticalCss %}{% endblock %}
Expand All @@ -25,9 +26,9 @@
{% endif %}

{# CSS #}
<link rel="{{ block('criticalCss')|length ? 'preload' : 'stylesheet' }}" href="{{ rev('/dist/app.css') }}" as="style" onload="this.onload=null;this.rel='stylesheet'">
<link rel="{{ block('criticalCss')|length and not craft.config.devMode ? 'preload' : 'stylesheet' }}" href="/dist/{{ rev('app.css') }}" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript>
<link rel="stylesheet" href="{{ rev('/dist/app.css') }}">
<link rel="stylesheet" href="/dist/{{ rev('app.css') }}">
</noscript>

</head>
Expand Down

0 comments on commit b4b3a42

Please sign in to comment.