Skip to content

Commit

Permalink
feat: handle default build/output/test config paths internally
Browse files Browse the repository at this point in the history
Closes #392
  • Loading branch information
brandonroberts committed May 24, 2023
1 parent b3d2cfe commit fb0bb5c
Show file tree
Hide file tree
Showing 16 changed files with 105 additions and 473 deletions.
30 changes: 6 additions & 24 deletions apps/analog-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,20 @@ import tsConfigPaths from 'vite-tsconfig-paths';
export default defineConfig(({ mode }) => {
return {
publicDir: 'src/public',
optimizeDeps: {
include: ['@angular/common', '@angular/forms'],
},
build: {
target: ['es2020'],
},
optimizeDeps: {
include: ['@angular/forms'],
},
plugins: [
analog({
ssrBuildDir: '../../dist/apps/analog-app/ssr',
entryServer: 'apps/analog-app/src/main.server.ts',
apiPrefix: 'api',
prerender: {
routes: ['/'],
},
vite: {
inlineStylesExtension: 'scss',
tsconfig:
mode === 'test'
? 'apps/analog-app/tsconfig.spec.json'
: 'apps/analog-app/tsconfig.app.json',
},
nitro: {
rootDir: 'apps/analog-app',
output: {
dir: '../../../dist/apps/analog-app/analog',
publicDir: '../../../dist/apps/analog-app/analog/public',
},
publicAssets: [{ dir: `../../../dist/apps/analog-app/client` }],
serverAssets: [
{ baseName: 'public', dir: `./dist/apps/analog-app/client` },
],
buildDir: '../../dist/apps/analog-app/.nitro',
prerender: {
routes: ['/'],
},
},
}),
tsConfigPaths({
Expand Down
11 changes: 2 additions & 9 deletions apps/astro-app/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { defineConfig } from 'astro/config';
import angular from "@analogjs/astro-angular";
import angular from '@analogjs/astro-angular';
import react from '@astrojs/react';

// https://astro.build/config
export default defineConfig({
outDir: '../../dist/apps/astro-app',
integrations: [
angular({
vite: {
tsconfig: 'apps/astro-app/tsconfig.app.json'
}
}),
react()
]
integrations: [angular(), react()],
});
17 changes: 0 additions & 17 deletions apps/blog-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ export default defineConfig(() => {
},
plugins: [
analog({
ssrBuildDir: '../../dist/apps/blog-app/ssr',
entryServer: 'apps/blog-app/src/main.server.ts',
static: true,
prerender: {
routes: async () => {
Expand All @@ -26,21 +24,6 @@ export default defineConfig(() => {
];
},
},
vite: {
tsconfig: 'apps/blog-app/tsconfig.app.json',
},
nitro: {
rootDir: 'apps/blog-app',
output: {
dir: '../../../dist/apps/blog-app/analog',
publicDir: '../../../dist/apps/blog-app/analog/public',
},
publicAssets: [{ dir: `../../../dist/apps/blog-app/client` }],
serverAssets: [
{ baseName: 'public', dir: `./dist/apps/blog-app/client` },
],
buildDir: '../../dist/apps/blog-app/.nitro',
},
}),
],
};
Expand Down
22 changes: 2 additions & 20 deletions apps/trpc-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,11 @@ export default defineConfig(({ mode }) => {
},
plugins: [
analog({
ssrBuildDir: '../../dist/apps/trpc-app/ssr',
entryServer: 'apps/trpc-app/src/main.server.ts',
vite: {
inlineStylesExtension: 'css',
tsconfig:
mode === 'test'
? 'apps/trpc-app/tsconfig.spec.json'
: 'apps/trpc-app/tsconfig.app.json',
},
nitro: {
rootDir: 'apps/trpc-app',
output: {
dir: '../../../dist/apps/trpc-app/analog',
publicDir: '../../../dist/apps/trpc-app/analog/public',
},
publicAssets: [{ dir: `../../../dist/apps/trpc-app/client` }],
serverAssets: [
{ baseName: 'public', dir: `./dist/apps/trpc-app/client` },
],
buildDir: '../../dist/apps/trpc-app/.nitro',
prerender: {
routes: ['/'],
},
prerender: {
routes: ['/'],
},
}),
tsConfigPaths({
Expand Down
6 changes: 1 addition & 5 deletions libs/top-bar/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ import angular from '@analogjs/vite-plugin-angular';
export default defineConfig(({ mode }) => {
return {
root: 'src',
plugins: [
angular({
tsconfig: 'libs/top-bar/tsconfig.spec.json',
}),
],
plugins: [angular()],
test: {
globals: true,
environment: 'jsdom',
Expand Down
4 changes: 1 addition & 3 deletions packages/astro-angular/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ This command:

- Installs the `@analogjs/astro-angular` package.
- Adds the `@analogjs/astro-angular` integration to the `astro.config.mjs` file.
- Installs the necessary dependencies to render Angular components on the server and client, and common Angular dependencies, such as `@angular/common` and `@angular/forms`.
- Installs the necessary dependencies to render Angular components on the server and client, and common Angular dependencies, such as `@angular/common`.

### Setting up the TypeScript config

Expand Down Expand Up @@ -113,8 +113,6 @@ export default defineConfig({
integrations: [
angular({
vite: {
tsconfig: 'path/to/tsconfig.app.json',
workspaceRoot: 'rootDir',
inlineStylesExtension: 'scss|sass|less',
},
}),
Expand Down
51 changes: 23 additions & 28 deletions packages/create-analog/README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,45 @@
# create-analog

## Scaffolding Your First Analog Project
Analog is the fullstack meta-framework for Angular.

## Features

- File-based routing
- SSR/SSG support with prerendering
- Support for API/server routes
- Support for using markdown as content routes
- Supports Angular CLI or Nx workspaces
- Powered by Vite

## Creating an Analog Project

With NPM:

```bash
$ npm create analog@latest
npm create analog@latest
```

With Yarn:

```bash
$ yarn create analog
yarn create analog
```

With PNPM:

```bash
$ pnpm create analog
```

Then follow the prompts!

You can also directly specify the project name and the template you want to use via additional command line options. For example, to scaffold an Angular, run:

```bash
# npm 6.x
npm create analog@latest my-angular-app --template angular-v15

# npm 7+, extra double-dash is needed:
npm create analog@latest my-angular-app -- --template angular-v15

# yarn
yarn create analog my-angular-app --template angular-v15

# pnpm
pnpm create analog my-angular-app --template angular-v15
pnpm create analog
```

Currently supported template presets include:
Follow the prompts to install the application dependencies and run the project in development mode!

- `angular-v16-prerelease`
- `angular-v15`
## Next Steps

You can use `.` for the project name to scaffold in the current directory.
Learn more at [analogjs.org](https://analogjs.org)

## Credits
## Community

This project is inspired by `create-vite`.
- Visit and Star the [GitHub Repo](https://github.com/analogjs/analog)
- Join the [Discord](https://chat.analogjs.org)
- Follow us on [Twitter](https://twitter.com/analogjs)
- Become a [Sponsor](https://github.com/sponsors/brandonroberts)
3 changes: 1 addition & 2 deletions packages/create-analog/template-angular-v16/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ Run `npm run test` to run unit tests with [Vitest](https://vitest.dev).

## Community

- Join the [Discord](https://discord.gg/mKC2Ec48U5)
- Visit and Star the [GitHub Repo](https://github.com/analogjs/analog)
- Visit the [Website](https://analogjs.org/)
- Join the [Discord](https://chat.analogjs.org)
- Follow us on [Twitter](https://twitter.com/analogjs)
- Become a [Sponsor](https://github.com/sponsors/brandonroberts)
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,11 @@ export default defineConfig(({ mode }) => {
noExternal: '@analogjs/trpc/**',
},
<% } %>
optimizeDeps: {
include: ['@angular/common', '@angular/forms'],
},
build: {
target: ['es2020'],
},
plugins: [
analog({
ssrBuildDir: '<%= offsetFromRoot %>dist/<%= appsDir %>/<%= projectName %>/ssr',
entryServer: '<%= appsDir %>/<%= projectName %>/src/main.server.ts',
vite: {
inlineStylesExtension: 'css',
tsconfig:
mode === 'test'
? '<%= appsDir %>/<%= projectName %>/tsconfig.spec.json'
: '<%= appsDir %>/<%= projectName %>/tsconfig.app.json',
},
nitro: {
rootDir: '<%= appsDir %>/<%= projectName %>',
output: {
dir: '<%= offsetFromRoot %>../dist/<%= appsDir %>/<%= projectName %>/analog',
publicDir: '<%= offsetFromRoot %>../dist/<%= appsDir %>/<%= projectName %>/analog/public',
},
publicAssets: [{ dir: `<%= offsetFromRoot %>../dist/<%= appsDir %>/<%= projectName %>/client` }],
serverAssets: [
{ baseName: 'public', dir: `./dist/<%= appsDir %>/<%= projectName %>/client` },
],
buildDir: '<%= offsetFromRoot %>dist/<%= appsDir %>/<%= projectName %>/.nitro',
},
prerender: {
routes: ['/'],
},
}),
analog(),
tsConfigPaths({
root: '<%= offsetFromRoot %>',
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export async function initializeAngularWorkspace(

if (lt(angularVersion, MINIMUM_SUPPORTED_ANGULAR_VERSION)) {
throw new Error(
stripIndents`AnalogJs only supports an Angular version of 15 and higher`
stripIndents`Analog only supports an Angular version of 15 and higher`
);
}

Expand Down
Loading

0 comments on commit fb0bb5c

Please sign in to comment.