-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow no config #61
Allow no config #61
Conversation
if (!config.projectRoot) config.projectRoot = '.'; | ||
if (!config.astroRoot) config.astroRoot = './astro'; | ||
if (!config.dist) config.dist = './_site'; | ||
if (!config.public) config.public = './public'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda dumb; can be improved. I just didn‘t want to add deepmerge
just yet as that can blow away user settings if not configured properly
projectRoot: '.', | ||
astroRoot: './astro', | ||
dist: './_site', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only deleted tests that had stock configurations; left other tests‘ configs that expanded on these
'.jsx': 'react' | ||
} | ||
}; | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added first pass at config docs
@@ -50,7 +72,7 @@ If you‘ve used [Svelte][svelte]’s styles before, Astro works almost the same | |||
<div class="scoped">I’m a scoped style</div> | |||
``` | |||
|
|||
#### Sass | |||
#### 👓 Sass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m 13 and need emojis on things apparently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ✨ LOVE IT ✨
const astroConfig = await loadConfig(rawRoot); | ||
return cmd(astroConfig); | ||
} catch (err) { | ||
console.error(colors.red(err.toString() || err)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
err.toString() || err
might be a crutch; I just do this out of habit whenever a stack trace is 100% not helpful and I want to hide it. Config validation is one such case
const type = (thing: any): string => (Array.isArray(thing) ? 'Array' : typeof thing); | ||
|
||
/** Throws error if a user provided an invalid config. Manually-implemented to avoid a heavy validation library. */ | ||
function validateConfig(config: any): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsonschema
is nice but I only just now realized how heavy it is 🙃
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our jsonschema object always gets out of date in Snowpack, I wish TS had a better idea of runtime type checking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran across Runtypes not too long ago. It‘s trying to be essentially a runtime for TS types. Could be something we look into, but it‘s about the same weight as jsonschema/probably has the same issues of keeping it updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
Changes
I wanted to set up more Astro projects without needing a
astro.config.mjs
, so I added basic defaults and very simple config validation.Testing
Docs
No docs changes (I think)