Skip to content

Commit

Permalink
chore: assets => _astro
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Jan 5, 2023
1 parent f48ccdf commit 4a1eeca
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .changeset/lovely-worms-invite.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
'astro': major
---

Builds chunks into the `assets` folder. This simplifies configuring immutable caching with your adapter provider as all files are now in the same `assets` folder.
The `assets` output directory has been renamed to `_astro`. In addition, all `chunks` will be generated inside of the `_astro` directory.

This simplifies configuring immutable caching with your adapter provider as all files are now in the same `_astro` directory.
16 changes: 8 additions & 8 deletions packages/astro/src/core/build/static-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ async function ssrBuild(opts: StaticBuildOptions, internals: BuildInternals, inp
input: [],
output: {
format: 'esm',
chunkFileNames: 'chunks/[name].[hash].mjs',
assetFileNames: 'assets/[name].[hash][extname]',
chunkFileNames: '_astro/chunks/[name].[hash].mjs',
assetFileNames: '_astro/[name].[hash][extname]',
...viteConfig.build?.rollupOptions?.output,
entryFileNames: opts.buildConfig.serverEntry,
},
Expand Down Expand Up @@ -212,9 +212,9 @@ async function clientBuild(
input: Array.from(input),
output: {
format: 'esm',
entryFileNames: 'assets/[name].[hash].js',
chunkFileNames: 'assets/chunks/[name].[hash].js',
assetFileNames: 'assets/[name].[hash][extname]',
entryFileNames: '_astro/[name].[hash].js',
chunkFileNames: '_astro/chunks/[name].[hash].js',
assetFileNames: '_astro/[name].[hash][extname]',
...viteConfig.build?.rollupOptions?.output,
},
preserveEntrySignatures: 'exports-only',
Expand Down Expand Up @@ -374,9 +374,9 @@ async function ssrMoveAssets(opts: StaticBuildOptions) {
const serverRoot =
opts.settings.config.output === 'static' ? opts.buildConfig.client : opts.buildConfig.server;
const clientRoot = opts.buildConfig.client;
const serverAssets = new URL('./assets/', serverRoot);
const clientAssets = new URL('./assets/', clientRoot);
const files = await glob('assets/**/*', {
const serverAssets = new URL('./_astro/', serverRoot);
const clientAssets = new URL('./_astro/', clientRoot);
const files = await glob('_astro/**/*', {
cwd: fileURLToPath(serverRoot),
});

Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/deno/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function createIntegration(args?: Options): AstroIntegration {
// Remove chunks, if they exist. Since we have bundled via esbuild these chunks are trash.
try {
const chunkFileNames =
_vite?.build?.rollupOptions?.output?.chunkFileNames ?? 'assets/chunks/chunk.[hash].mjs';
_vite?.build?.rollupOptions?.output?.chunkFileNames ?? '_astro/chunks/chunk.[hash].mjs';
const chunkPath = npath.dirname(chunkFileNames);
const chunksDirUrl = new URL(chunkPath + '/', _buildConfig.server);
await fs.promises.rm(chunksDirUrl, { recursive: true, force: true });
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/image/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default function integration(options: IntegrationOptions = {}): AstroInte
// For the Squoosh service, copy all wasm files to dist/chunks.
// Because the default loader is dynamically imported (above),
// Vite will bundle squoosh to dist/chunks and expect to find the wasm files there
await copyWasmFiles(new URL('./assets/chunks', dir));
await copyWasmFiles(new URL('./_astro/chunks', dir));
}

if (loader && 'transform' in loader && staticImages.size > 0) {
Expand All @@ -166,7 +166,7 @@ export default function integration(options: IntegrationOptions = {}): AstroInte
},
'astro:build:ssr': async () => {
if (resolvedOptions.serviceEntryPoint === '@astrojs/image/squoosh') {
await copyWasmFiles(new URL('./assets/chunks/', _buildConfig.server));
await copyWasmFiles(new URL('./_astro/chunks/', _buildConfig.server));
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function bundleServerEntry({ serverEntry, server }: BuildConfig, vite: any
// Remove chunks, if they exist. Since we have bundled via esbuild these chunks are trash.
try {
const chunkFileNames =
vite?.build?.rollupOptions?.output?.chunkFileNames ?? 'assets/chunks/chunk.[hash].mjs';
vite?.build?.rollupOptions?.output?.chunkFileNames ?? '_astro/chunks/chunk.[hash].mjs';
const chunkPath = npath.dirname(chunkFileNames);
const chunksDirUrl = new URL(chunkPath + '/', server);
await fs.promises.rm(chunksDirUrl, { recursive: true, force: true });
Expand Down

0 comments on commit 4a1eeca

Please sign in to comment.