-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up learn-german app build config
- Loading branch information
1 parent
d356f82
commit 0d2bd30
Showing
2 changed files
with
37 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,40 @@ | ||
# service worker | ||
|
||
No longer necessary to write service worker files manually as we use the vite plugin. This folder is just for documentation. | ||
|
||
# Generating a build file array | ||
|
||
We could add a custom plug-in to generate a file that includes all the generated assets. `generateBundle` is a Vite API that can be called after the bundle is generated. | ||
|
||
```ts | ||
plugins: [ | ||
nxViteTsPaths(), | ||
// VitePWA({ | ||
// registerType: 'autoUpdate', | ||
// manifest: manifestObj as any, | ||
// workbox: { | ||
// globPatterns: ['**/*.{js,css,html,ico,png,svg}'], | ||
// }, | ||
// }), | ||
{ | ||
name: 'collect-build-files', | ||
generateBundle(options, bundle) { | ||
const files = [] | ||
|
||
for (const fileName in bundle) { | ||
if (Object.prototype.hasOwnProperty.call(bundle, fileName)) { | ||
files.push(fileName) | ||
} | ||
} | ||
|
||
const outDir = options.dir || 'dist' | ||
const outputPath = path.resolve(outDir, 'build-files.js') | ||
const fileContent = `export const buildFiles = ${JSON.stringify(files, null, 2)};` | ||
|
||
fs.writeFileSync(outputPath, fileContent, 'utf-8') | ||
|
||
console.log(`Build files array written to: ${outputPath}`) | ||
}, | ||
}, | ||
], | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters