#how do I tell astro to put its files in a child directory?

1 messages · Page 1 of 1 (latest)

granite star
#

I have run the astro initiatilzation setup in an existing repository and currently have it setup so that Astro is inside a child folder, I moved all the relevant package.json/script commands into the root folder, but whenever I run npm run build it seems to be generating an env.d.ts in a folder that's not the astro folder?

For clarity, this is my current repo structure, with annotated notes explaining my issue:

├── LICENSE
├── README.md
├── package-lock.json
├── package.json
├── panel <--- this is the astro folder
│   ├── README.md
│   ├── astro.config.mjs
│   ├── public
│   │   └── favicon.svg
│   ├── src
│   │   ├── components
│   │   │   └── Card.astro
│   │   ├── env.d.ts
│   │   ├── layouts
│   │   │   └── Layout.astro
│   │   └── pages
│   │       └── index.astro
│   └── tsconfig.json
├── src <--- this is a separate thing
│   ├── encrypt.ts
│   ├── env.d.ts <--- why is this here?
│   └── server.ts
└── tsconfig.json

Should I just install astro manually instead of using the cli tool? I'm not sure how I can get it to stop putting that env.d.ts in the wrong folder... I took a look at https://astro.build/config but I don't think that will help solve this problem?

brave merlinBOT
#
No-one around right now?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.

hot yew
#

I'm going to assume astro builds up a relative path based on package.json? In which case IDK js too well but you could probably have a package.json in that folder and also for the src (encrypt.ts?) folder

granite star
#

I did have a package.json in the original panel folder (that Astro generated) but I moved everything to the parent package.json and then deleted it Hmm

shut gyro
#

perhaps put the proper project root inside astro.config.mjs using this:

granite star
#

I had tried that and it didn't seem to solve my problem either, though I'm not sure if it's because I just don't understand what the "project root" is. I'm not sure if it's referring to the panel/ directory or if it's referring to the parent folder of the entire project. I have this in my astro.config.mjs: ```mjs
import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({
root: './panel',
srcDir: './panel/src'
});

shut gyro
#

what directory are you running the build command from

#

the same as the package.json?

granite star
#

yes, the parent folder is called bot-server\ and the astro folder is located at bot-server\panel - I'm running the commands while in bot-server\

#

I notice this while running the build script 09:18:38 PM [astro] Missing pages directory: src/pages so it seems like it's just using the bot-server/src directory no matter what instead of bot-server/panel/src which is what had me confused

shut gyro
#

import { defineConfig } from 'astro/config';

// https://astro.build/config
export default defineConfig({
    root: './panel',
    srcDir: './src'
});

maybe? haha

granite star
#

still nope cody_hmm I event tried doing an absolute path and it's still putting em in the wrong src folder

#

okay so I found out where in the astro node module the settings are being loaded, and it looks like the config file isn't actually loading at all? ```root: URL {
href: 'file:///home/<name>/dev/digittron-server/',
origin: 'null',
protocol: 'file:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/home/<name>/dev/digittron-server/',
search: '',
searchParams: URLSearchParams {},
hash: ''
},
srcDir: URL {
href: 'file:///home/<name>/dev/digittron-server/src/',
origin: 'null',
protocol: 'file:',
username: '',
password: '',
host: '',
hostname: '',
port: '',
pathname: '/home/<name>/dev/digittron-server/src/',
search: '',
searchParams: URLSearchParams {},
hash: ''
}

#

ah, I got it. Looks like the config file must be in the project root, otherwise you have to specify the location of the config file yourself in the cli command.