Skip to content

Commit

Permalink
Add changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
hariombalhara committed Jul 7, 2021
1 parent 8e3b181 commit d885066
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 31 deletions.
5 changes: 5 additions & 0 deletions .changeset/pink-poets-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

ServiceWorker files exclusion support available through svelte.config.js
70 changes: 39 additions & 31 deletions packages/kit/src/core/create_manifest_data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,44 @@ import glob from 'tiny-glob/sync.js';

const specials = new Set(['__layout', '__layout.reset', '__error']);

/**
*
* @param {import('types/config').ValidatedConfig} config
* @returns {import('types/internal').ManifestData['assets']}
*/
function get_assets_list(config) {
const assets_dir = config.kit.files.assets;
/**
* @type {import('types/internal').Asset[]}
*/
let assets = [];
if (fs.existsSync(assets_dir)) {
/**
* @type {string[]}
*/
const exclusions = config.kit.serviceWorker.exclude || [];

exclusions.push('**/.DS_STORE');

/**
* @type {string[]}
*/
let excluded_paths = [];

exclusions.forEach((exclusion) => {
excluded_paths = [
...excluded_paths,
...glob(exclusion, {
cwd: assets_dir,
dot: true
})
];
});
assets = list_files(assets_dir, '', [], excluded_paths);
}
return assets;
}

/**
* @param {{
* config: import('types/config').ValidatedConfig;
Expand Down Expand Up @@ -238,38 +276,8 @@ export default function create_manifest_data({ config, output, cwd = process.cwd

walk(config.kit.files.routes, [], [], [layout], [error]);

const assets_dir = config.kit.files.assets;
/**
* @type {import('types/internal').Asset[]}
*/
let assets = [];
if (fs.existsSync(assets_dir)) {
/**
* @type {string[]}
*/
const exclusions = config.kit.serviceWorker.exclude || [];

exclusions.push('**/.DS_STORE');

/**
* @type {string[]}
*/
let excluded_paths = [];

exclusions.forEach((exclusion) => {
excluded_paths = [
...excluded_paths,
...glob(exclusion, {
cwd: assets_dir,
dot: true
})
];
});
assets = list_files(assets_dir, '', [], excluded_paths);
}

return {
assets,
assets: get_assets_list(config),
layout,
error,
components,
Expand Down

0 comments on commit d885066

Please sign in to comment.