Skip to content

Commit

Permalink
Merge pull request #243 from thegalactiks/remove-assets-dir
Browse files Browse the repository at this point in the history
Remove useless assets dir in public dir
  • Loading branch information
emmanuelgautier authored Oct 23, 2024
2 parents dba4a3c + 21a46b2 commit 6401aa2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-actors-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@galactiks/astro-integration': patch
---

remove useless assets dir during build
10 changes: 2 additions & 8 deletions packages/adapters/astro/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
lstatSync,
mkdirSync,
readdirSync,
rmdirSync,
symlinkSync,
unlinkSync,
} from 'node:fs';
Expand Down Expand Up @@ -53,7 +52,6 @@ export default function createPlugin(_: GalactiksOptions): AstroIntegration {

let assetsPath: string;
let publicPath: string;
let publicAssetsPath: string;

return {
name: '@galactiks/astro-integration',
Expand All @@ -76,11 +74,9 @@ export default function createPlugin(_: GalactiksOptions): AstroIntegration {
galactiksConfig = setConfig('content.assets', assetsPath);

publicPath = fileURLToPath(config.publicDir);
mkdirSync(publicPath, { recursive: true })
galactiksConfig = setConfig('content.public', publicPath);

publicAssetsPath = join(publicPath, 'assets');
mkdirSync(publicAssetsPath, { recursive: true });

updateConfig({
site: galactiksConfig.webManifest.start_url,
trailingSlash,
Expand All @@ -94,11 +90,10 @@ export default function createPlugin(_: GalactiksOptions): AstroIntegration {

removeDirSymbolicLinks(assetsPath);
removeDirSymbolicLinks(publicPath);
removeDirSymbolicLinks(publicAssetsPath);

symlinkDir(assetsPath, galactiksConfigContentAssets);
symlinkDir(publicPath, galactiksConfigContentPublic);
symlinkDir(publicAssetsPath, galactiksConfigContentAssets);
symlinkDir(publicPath, galactiksConfigContentAssets);

if (command === 'dev') {
addWatchFile(galactiksConfig.content.generated);
Expand All @@ -109,7 +104,6 @@ export default function createPlugin(_: GalactiksOptions): AstroIntegration {

'astro:build:done': () => {
removeDirSymbolicLinks(assetsPath);
rmdirSync(publicAssetsPath, { recursive: true });
removeDirSymbolicLinks(publicPath);
},
},
Expand Down

0 comments on commit 6401aa2

Please sign in to comment.