Skip to content

Commit dd56250

Browse files
committed
Add documentation and simplify code
1 parent f8ed0d6 commit dd56250

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

packages/kit/src/core/create_manifest_data/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ export default function create_manifest_data({ config, output, cwd = process.cwd
248248
* @type {string[]}
249249
*/
250250
let exclusions = config.kit.serviceWorker.filesExclusions || [];
251+
252+
// .DS_STORE files are automatically removed to keep the compatiblity
251253
exclusions = [...exclusions, '**/.DS_STORE'];
252254

253255
/**
@@ -403,7 +405,7 @@ function get_pattern(segments, add_trailing_slash) {
403405
* @param {string} dir
404406
* @param {string} path
405407
* @param {import('types/internal').Asset[]} files
406-
* @param {string[]} excludedPaths
408+
* @param {string[]} excludedPaths Paths relative to dir which should be excluded from files list.
407409
*/
408410
function list_files(dir, path, files = [], excludedPaths = []) {
409411
fs.readdirSync(dir).forEach((file) => {
@@ -415,11 +417,7 @@ function list_files(dir, path, files = [], excludedPaths = []) {
415417
if (stats.isDirectory()) {
416418
list_files(full, joined, files, excludedPaths);
417419
} else {
418-
if (
419-
excludedPaths.some((exclusion) => {
420-
return exclusion === joined;
421-
})
422-
) {
420+
if (excludedPaths.includes(joined)) {
423421
return;
424422
}
425423
files.push({

packages/kit/types/config.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export type ValidatedConfig = {
9595
hostHeader: string;
9696
hydrate: boolean;
9797
serviceWorker: {
98-
// Globs relative to assets folder.
98+
// Glob patterns relative to `files.assets` dir. Files matching this would not be available in $service-worker.files
99+
// e.g. if `files.assets` has value `static` then ['og-tags-images/**/*'] would match all files under `static/og-tags-images` dir.
100+
// As og-tags-images are never loaded by a normal client(browser), they can be comfortably skipped from here.
99101
filesExclusions: string[];
100102
};
101103
package: {

0 commit comments

Comments
 (0)