Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for precaching generated assets in sw.js #380

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions app/tools/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,42 @@ export default defineConfig({
'lib.i18n': resolve('../lib/i18n/index.ts'),
'lib.view': resolve('../lib/view/index.ts'),
},
plugins: [
{
name: 'custom-sw-plugin',
generateBundle(options, bundle) {
const swCode = `
import { precacheAndRoute } from 'workbox-precaching';

precacheAndRoute([
'/build-53e87ed8.svg',
'/close-444dc9a6.svg',
'/code-74870b2e.svg',
'/build-53e87ed8.svg',
'/close-444dc9a6.svg',
'/code-74870b2e.svg',
'/exportDrawing-aee43b5d.svg',
'/help-a0383ce2.svg',
'/logo-3080f493.png',
'/mouse-46cf41ce.svg',
'/pin-8515e01d.svg',
'/reset-a8de2102.svg',
'/run-123f2282.svg',
'/saveProjectHTML-e442bff6.svg',
'/startRecording-5dec9e0d.svg',
'/stop-aa193098.svg',
'/stopRecording-48f9a011.svg',
'/unpin-427cfcc6.svg'
]);`;

this.emitFile({
type: 'asset',
fileName: 'sw.js',
source: swCode,
});
},
},
]
},
},
});
4 changes: 2 additions & 2 deletions modules/singer/src/singer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const currentpitch = new CurrentPitch(testKeySignature, new Temperament(), 1, 4)
const _stateObj = { ..._defaultSynthStateValues };

/** Proxy to the synth state parameters. */
const _state = new Proxy(_stateObj, {
export const _state = new Proxy(_stateObj, {
set: (_, key, value) => {
if (key === 'beatsPerMinute') {
_stateObj.beatsPerMinute = value;
Expand All @@ -37,7 +37,7 @@ const _state = new Proxy(_stateObj, {
});

/** Default synth **/
const _defaultSynth = new Tone.Synth().toDestination();
export const _defaultSynth = new Tone.Synth().toDestination();

// -- private functions ----------------------------------------------------------------------------

Expand Down