Skip to content

Commit

Permalink
Add documentation and simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
hariombalhara committed Jun 7, 2021
1 parent f8ed0d6 commit dd56250
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 4 additions & 6 deletions packages/kit/src/core/create_manifest_data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ export default function create_manifest_data({ config, output, cwd = process.cwd
* @type {string[]}
*/
let exclusions = config.kit.serviceWorker.filesExclusions || [];

// .DS_STORE files are automatically removed to keep the compatiblity
exclusions = [...exclusions, '**/.DS_STORE'];

/**
Expand Down Expand Up @@ -403,7 +405,7 @@ function get_pattern(segments, add_trailing_slash) {
* @param {string} dir
* @param {string} path
* @param {import('types/internal').Asset[]} files
* @param {string[]} excludedPaths
* @param {string[]} excludedPaths Paths relative to dir which should be excluded from files list.
*/
function list_files(dir, path, files = [], excludedPaths = []) {
fs.readdirSync(dir).forEach((file) => {
Expand All @@ -415,11 +417,7 @@ function list_files(dir, path, files = [], excludedPaths = []) {
if (stats.isDirectory()) {
list_files(full, joined, files, excludedPaths);
} else {
if (
excludedPaths.some((exclusion) => {
return exclusion === joined;
})
) {
if (excludedPaths.includes(joined)) {
return;
}
files.push({
Expand Down
4 changes: 3 additions & 1 deletion packages/kit/types/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ export type ValidatedConfig = {
hostHeader: string;
hydrate: boolean;
serviceWorker: {
// Globs relative to assets folder.
// Glob patterns relative to `files.assets` dir. Files matching this would not be available in $service-worker.files
// e.g. if `files.assets` has value `static` then ['og-tags-images/**/*'] would match all files under `static/og-tags-images` dir.
// As og-tags-images are never loaded by a normal client(browser), they can be comfortably skipped from here.
filesExclusions: string[];
};
package: {
Expand Down

0 comments on commit dd56250

Please sign in to comment.