Skip to content
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

Adds an integration starter example #4877

Merged
merged 11 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions examples/integration/demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# build output
dist/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store
2 changes: 2 additions & 0 deletions examples/integration/demo/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Expose Astro dependencies for `pnpm` users
shamefully-hoist=true
6 changes: 6 additions & 0 deletions examples/integration/demo/.stackblitzrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"startCommand": "npm start",
"env": {
"ENABLE_CJS_IMPORTS": true
}
}
4 changes: 4 additions & 0 deletions examples/integration/demo/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
11 changes: 11 additions & 0 deletions examples/integration/demo/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
45 changes: 45 additions & 0 deletions examples/integration/demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Astro Starter Kit: Minimal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be the same README file as the minimal starter kit. I'm assuming this should be customized for this starter?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! I ended up removing the demo project and added a main README for the integration example (based on the component starter)


```
npm create astro@latest -- --template minimal
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/minimal)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!

## 🚀 Project Structure

Inside of your Astro project, you'll see the following folders and files:

```
/
├── public/
├── src/
│ └── pages/
│ └── index.astro
└── package.json
```

Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.

There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.

Any static assets, like images, can be placed in the `public/` directory.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :--------------------- | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:3000` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
7 changes: 7 additions & 0 deletions examples/integration/demo/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'astro/config';
import myIntegration from '@example/my-integration';

// https://astro.build/config
export default defineConfig({
integrations: [myIntegration()],
});
17 changes: 17 additions & 0 deletions examples/integration/demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@example/my-integration-demo",
"type": "module",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@example/my-integration": "workspace:*",
"astro": "^1.3.0"
}
}
13 changes: 13 additions & 0 deletions examples/integration/demo/public/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions examples/integration/demo/sandbox.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"infiniteLoopProtection": true,
"hardReloadOnChange": false,
"view": "browser",
"template": "node",
"container": {
"port": 3000,
"startScript": "start",
"node": "14"
}
}
1 change: 1 addition & 0 deletions examples/integration/demo/src/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="astro/client" />
15 changes: 15 additions & 0 deletions examples/integration/demo/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
---

<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width" />
<meta name="generator" content={Astro.generator} />
<title>Astro</title>
</head>
<body>
<h1>Astro</h1>
</body>
</html>
3 changes: 3 additions & 0 deletions examples/integration/demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/base"
}
15 changes: 15 additions & 0 deletions examples/integration/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@example/integration",
"type": "module",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "astro --root demo dev",
"start": "astro --root demo dev",
"build": "astro --root demo build",
"preview": "astro --root demo preview"
},
"dependencies": {
"astro": "^1.3.0"
}
}
36 changes: 36 additions & 0 deletions examples/integration/packages/my-integration/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { AstroIntegration } from 'astro';

export default function createIntegration(): AstroIntegration {
return {
name: '@example/my-integration',
hooks: {
'astro:config:setup': ({
config,
command,
updateConfig,
addRenderer,
injectScript,
injectRoute,
}) => {
// Used to extend the project config. This includes updating the Astro config,
// applying Vite plugins, adding component renderers, and injecting scripts onto the page.
console.log('astro:config:setup');
},
'astro:server:setup': ({ server }) => {
// Used to update Vite server options and middleware.
console.log('astro:server:setup');
},
'astro:build:start': ({ buildConfig }) => {
// Used to set up any global objects or clients needed during a production build.
// This can also extend the build configuration options in the adapter API.
console.log('astro:build:start');
},
'astro:build:done': ({ dir, routes }) => {
// Used to access generated routes and assets for extension (ex. copy content into the generated /assets directory).
// If you plan to transform generated assets, we recommend exploring the Vite Plugin API and
// configuring via astro:config:setup instead.
console.log('astro:build:done');
},
},
};
}
22 changes: 22 additions & 0 deletions examples/integration/packages/my-integration/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "@example/my-integration",
"private": true,
"version": "0.0.1",
"type": "module",
"exports": {
".": "./index.ts"
},
"files": [
"index.ts"
],
"keywords": [
"astro-component"
],
"scripts": {},
"devDependencies": {
"astro": "^1.3.0"
},
"peerDependencies": {
"astro": "^1.3.0"
}
}
3 changes: 3 additions & 0 deletions examples/integration/packages/my-integration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/base"
}
3 changes: 3 additions & 0 deletions examples/integration/pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
packages:
- 'packages/**/*'
- 'demo'
11 changes: 11 additions & 0 deletions examples/integration/sandbox.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"infiniteLoopProtection": true,
"hardReloadOnChange": false,
"view": "browser",
"template": "node",
"container": {
"port": 3000,
"startScript": "start",
"node": "14"
}
}
3 changes: 3 additions & 0 deletions examples/integration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/base"
}
20 changes: 20 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.