changes entrypoints and tweaks manifest augmenter

This commit is contained in:
ChaosExAnima 2025-04-01 12:12:40 +02:00
parent fa4243c28c
commit f72699db08
No known key found for this signature in database
GPG Key ID: 8F2B333100FB6117
3 changed files with 13 additions and 29 deletions

View File

@ -1,8 +0,0 @@
<html>
<head>
<script type="module" src="./application.ts"></script>
</head>
<body>
<div id="mastodon"></div>
</body>
</html>

View File

@ -13,13 +13,6 @@ export interface Options {
* @default ['sha384']
*/
algorithms?: Algorithm[];
/**
* Path of the manifest files that should be read and augmented with the
* integrity hash, relative to `outDir`.
* @default ['manifest.json', 'manifest-assets.json']
*/
manifestPaths?: string[];
}
declare module 'vite' {
@ -29,26 +22,14 @@ declare module 'vite' {
}
export function manifestSRI(options: Options = {}): Plugin {
const {
algorithms = ['sha384'],
manifestPaths = [
'.vite/manifest.json',
'.vite/manifest-assets.json',
'manifest.json',
'manifest-assets.json',
],
} = options;
const { algorithms = ['sha384'] } = options;
return {
name: 'vite-plugin-manifest-sri',
apply: 'build',
enforce: 'post',
async writeBundle({ dir }) {
await Promise.all(
manifestPaths.map((path) =>
augmentManifest(path, algorithms, dir ?? ''),
),
);
await augmentManifest('manifest.json', algorithms, dir ?? '');
},
};
}

View File

@ -13,6 +13,17 @@ export default defineConfig({
emptyOutDir: true,
manifest: 'manifest.json',
rollupOptions: {
input: {
admin: path.resolve(__dirname, 'app/javascript/entrypoints/admin.tsx'),
application: path.resolve(
__dirname,
'app/javascript/entrypoints/application.ts',
),
twoFactor: path.resolve(
__dirname,
'app/javascript/entrypoints/two_factor_authentication.ts',
),
},
output: {
chunkFileNames: (chunkInfo) => {
if (