Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 8 additions & 4 deletions convert/convertManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ export function convertManifest(dataDir: string, verbose: number) {
contents = lines
.map((line) => {
if (line.includes('start_url')) {
const path = process.env.BUILD_BASE_PATH ? process.env.BUILD_BASE_PATH : '.';
line = ` "start_url" : "${path}/",`;
const urlPath = process.env.BUILD_BASE_PATH ? process.env.BUILD_BASE_PATH : '.';
line = ` "start_url" : "${urlPath}/",`;
}
Comment thread
chrisvire marked this conversation as resolved.
if (line.includes('scope')) {
const path = process.env.BUILD_BASE_PATH ? process.env.BUILD_BASE_PATH : '/';
line = ` "scope" : "${path}",`;
const scopePath = process.env.BUILD_BASE_PATH
? process.env.BUILD_BASE_PATH.endsWith('/')
? process.env.BUILD_BASE_PATH
: process.env.BUILD_BASE_PATH + '/'
: '/';
line = ` "scope" : "${scopePath}",`;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if (line.includes('"src":') && line.includes('./icons')) {
const srcMatch = line.match(/"src"\s*:\s*"\.\/([^"]+)"/);
Expand Down
10 changes: 9 additions & 1 deletion svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ const packageJson = JSON.parse(readFileSync('package.json', 'utf-8'));
const templateVersion = packageJson.version;
const buildTimestamp = Date.now();

// Scope should end with a slash if defined
// BUILD_BASE_PATH should not have a trailing slash, but just make sure
const serviceWorkerScope = process.env.BUILD_BASE_PATH
? process.env.BUILD_BASE_PATH.endsWith('/')
? process.env.BUILD_BASE_PATH
: process.env.BUILD_BASE_PATH + '/'
: '/';

/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
Expand Down Expand Up @@ -34,7 +42,7 @@ const config = {
},
serviceWorker: {
options: {
scope: process.env.BUILD_BASE_PATH
scope: serviceWorkerScope
}
},
version: {
Expand Down