Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/sharp-crews-pull.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Add support for avif images format
9 changes: 3 additions & 6 deletions packages/cli/lib/commands/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const { addScripts, install, initGit } = require('../lib/setup');
const { validateArgs } = require('./validate-args');

const ORG = 'preactjs-templates';
const RGX = /\.(woff2?|ttf|eot|jpe?g|ico|png|gif|webp|mp4|mov|ogg|webm)(\?.*)?$/i;
const RGX =
/\.(woff2?|ttf|eot|jpe?g|ico|png|gif|webp|avif|mp4|mov|ogg|webm)(\?.*)?$/i;
const isMedia = str => RGX.test(str);
const capitalize = str => str.charAt(0).toUpperCase() + str.substring(1);

Expand Down Expand Up @@ -176,11 +177,7 @@ async function fetchTemplates() {
// If cache file doesn't exist, then hit the API and fetch the data
if (!existsSync(cacheFilePath)) {
const repos = await fetch(TEMPLATES_REPO_URL).then(r => r.json());
await writeFile(
cacheFilePath,
JSON.stringify(repos, null, 2),
'utf-8'
);
await writeFile(cacheFilePath, JSON.stringify(repos, null, 2), 'utf-8');
}

// update the cache file without blocking the rest of the tasks.
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/lib/lib/webpack/webpack-base-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ module.exports = function createBaseConfig(env) {
loader: require.resolve('raw-loader'),
},
{
test: /\.(svg|woff2?|ttf|eot|jpe?g|png|webp|gif|mp4|mov|ogg|webm)(\?.*)?$/i,
test: /\.(svg|woff2?|ttf|eot|jpe?g|png|webp|avif|gif|mp4|mov|ogg|webm)(\?.*)?$/i,
loader: isProd
? require.resolve('file-loader')
: require.resolve('url-loader'),
Expand Down
9 changes: 7 additions & 2 deletions packages/cli/lib/lib/webpack/webpack-client-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ async function clientConfig(env) {
/200\.html$/,
/\.esm.js$/,
/\.css$/,
/\.(png|jpg|svg|gif|webp)$/,
/\.(png|jpg|svg|gif|webp|avif)$/,
],
webpackCompilationPlugins: [
new webpack.DefinePlugin({
Expand All @@ -73,7 +73,12 @@ async function clientConfig(env) {
swInjectManifest.push(
new InjectManifest({
swSrc: swPath,
include: [/200\.html$/, /\.js$/, /\.css$/, /\.(png|jpg|svg|gif|webp)$/],
include: [
/200\.html$/,
/\.js$/,
/\.css$/,
/\.(png|jpg|svg|gif|webp|avif)$/,
],
exclude: [/\.esm\.js$/],
})
);
Expand Down