Export defineConfig helper (#2803)

* feat: add astro/config entrypoint

* chore: update examples to use `defineConfig` util

* chore: prettier fix

* chore: add changeset
This commit is contained in:
Nate Moore 2022-03-15 15:27:17 -05:00 committed by GitHub
parent 2d95541b52
commit 2b76ee8d75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 101 additions and 205 deletions

View file

@ -0,0 +1,15 @@
---
'astro': patch
---
Add an `astro/config` entrypoint with a `defineConfig` utility.
Config files can now be easily benefit from Intellisense using the following approach:
```js
import { defineConfig } from 'astro/config';
export default defineConfig({
renderers: []
})
```

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable the Preact renderer to support Preact JSX components.
renderers: ['@astrojs/renderer-preact'],
});

View file

@ -1,14 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// Enable the Preact renderer to support Preact JSX components.
// https://astro.build/config
export default defineConfig({
renderers: ['@astrojs/renderer-preact'],
buildOptions: {
site: 'https://example.com/',

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Comment out "renderers: []" to enable Astro's default component support.
renderers: [],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
renderers: [
// Enable the Preact renderer to support Preact JSX components.
'@astrojs/renderer-preact',

View file

@ -1,8 +1,6 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// Comment out "renderers: []" to enable Astro's default component support.
// https://astro.build/config
export default defineConfig({
renderers: [],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// No renderers are needed for AlpineJS support, just use Astro components!
renderers: [],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable the lit renderer to support LitHTML components and templates.
renderers: ['@astrojs/renderer-lit'],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable many renderers to support all different kinds of components.
renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue', '@astrojs/renderer-solid'],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable the Preact renderer to support Preact JSX components.
renderers: ['@astrojs/renderer-preact'],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable the React renderer to support React JSX components.
renderers: ['@astrojs/renderer-react'],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable the Solid renderer to support Solid JSX components.
renderers: ['@astrojs/renderer-solid'],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable the Svelte renderer to support Svelte components.
renderers: ['@astrojs/renderer-svelte'],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable the Vue renderer to support Vue components.
renderers: ['@astrojs/renderer-vue'],
});

View file

@ -1,8 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Comment out "renderers: []" to enable Astro's default component support.
renderers: [],
});

View file

@ -1,8 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Comment out "renderers: []" to enable Astro's default component support.
renderers: [],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable the Preact renderer to support Preact JSX components.
renderers: ['@astrojs/renderer-preact'],
});

View file

@ -1,6 +1,6 @@
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
export default defineConfig({
renderers: ['@astrojs/renderer-svelte'],
vite: {
server: {

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Set "renderers" to "[]" to disable all default, builtin component support.
renderers: [],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Comment out "renderers: []" to enable Astro's default component support.
buildOptions: {
site: 'http://example.com/blog',

View file

@ -1,15 +1,9 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
import { defineConfig } from 'astro/config';
import astroRemark from '@astrojs/markdown-remark';
import addClasses from './add-classes.mjs';
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable Custom Markdown options, plugins, etc.
renderers: [],
markdownOptions: {

View file

@ -1,14 +1,8 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
import { defineConfig } from 'astro/config';
import astroRemark from '@astrojs/markdown-remark';
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable Custom Markdown options, plugins, etc.
renderers: [],
markdownOptions: {

View file

@ -1,12 +1,6 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue'],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable many renderers to support all different kinds of components.
renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-react', '@astrojs/renderer-svelte', '@astrojs/renderer-vue', '@astrojs/renderer-solid'],
});

View file

@ -1,13 +1,7 @@
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
import { defineConfig } from 'astro/config';
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
// Enable the Preact renderer to support Preact JSX components.
renderers: ['@astrojs/renderer-preact'],
});

View file

@ -1,15 +1,8 @@
import { defineConfig } from 'astro/config';
import { VitePWA } from 'vite-plugin-pwa';
// Full Astro Configuration API Documentation:
// https://docs.astro.build/reference/configuration-reference
// @type-check enabled!
// VSCode and other TypeScript-enabled text editors will provide auto-completion,
// helpful tooltips, and warnings if your exported object is invalid.
// You can disable this by removing "@ts-check" and `@type` comments below.
// @ts-check
export default /** @type {import('astro').AstroUserConfig} */ ({
// https://astro.build/config
export default defineConfig({
renderers: [],
vite: {
plugins: [VitePWA()],

7
packages/astro/config.d.ts vendored Normal file
View file

@ -0,0 +1,7 @@
type AstroUserConfig = import('./dist/types/@types/astro').AstroUserConfig;
/**
* See the full Astro Configuration API Documentation
* https://astro.build/config
*/
export function defineConfig(config: AstroUserConfig): AstroUserConfig;

View file

@ -0,0 +1,3 @@
export function defineConfig(config) {
return config;
}

View file

@ -16,6 +16,7 @@
"exports": {
".": "./astro.js",
"./env": "./env.d.ts",
"./config": "./config.mjs",
"./internal": "./internal.js",
"./app/node": "./dist/core/app/node.js",
"./client/*": "./dist/runtime/client/*",
@ -45,6 +46,8 @@
"components",
"dist",
"astro.js",
"config.d.ts",
"config.mjs",
"env.d.ts",
"README.md",
"vendor"