Skip to content

Commit

Permalink
fix(daffio): unable to resolve assets in dev server (#2977)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 authored Aug 14, 2024
1 parent 4858161 commit c061885
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DAFF_ROOT=/workspace/daffodil
11 changes: 6 additions & 5 deletions apps/daffio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
* [Angular CLI](https://cli.angular.io/) - `npm install -g @angular/cli`

### Getting Started
1. `lerna run build`
2. `ng serve --project=daffio`
3. Navigate to `localhost:4200` in your browser of choice
1. Create a `.env` in your working directory with the absolute path to your daffodil project root set to `DAFF_ROOT`, e.g `echo "DAFF_ROOT=/workspace/daffodil" >> .env`
2. `lerna run build`
3. `ng serve --project=daffio`
4. Navigate to `localhost:4200` in your browser of choice

### Project Overview
Daff.io is the web application that explains the features of `@daffodil` and house the documentation of `@daffodil`.

### Contributing to daff.io
Generally speaking, you don't want to depend directly on the source of a dependency when developing, as that can cause unexpected issues at build and deployment time, as well as downstream effects for the developers that depend on your libraries. Yet, there are instances when quick development cycles that don't require a full rebuild can drastically improve development efficiency. E.g. changing styles in a component library.
Generally speaking, you don't want to depend directly on the source of a dependency when developing, as that can cause unexpected issues at build and deployment time, as well as downstream effects for the developers that depend on your libraries. Yet, there are instances when quick development cycles that don't require a full rebuild can drastically improve development efficiency. E.g. changing styles in a component library.

For this reason, we have opted to create a secondary project `daffio-dev` which depends directly on the `@daffodil` libraries source. This can be utilized for rapid feature prototyping, but should be used sparingly.
For this reason, we have opted to create a secondary project `daffio-dev` which depends directly on the `@daffodil` libraries source. This can be utilized for rapid feature prototyping, but should be used sparingly.

> daffio-dev does not support `lint`ing or `build`ing, it only serves the purposes of the internal `@daffodil` development team.
Expand Down
10 changes: 8 additions & 2 deletions apps/daffio/src/app/docs/services/docs-path-server.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { Provider } from '@angular/core';
import { join } from 'path';
import { config } from 'dotenv';
import { resolve } from 'path';

import { DAFFIO_DOCS_PATH_TOKEN } from './docs-path.token';
import { environment } from '../../../environments/environment';

/**
* The path on the server to the docs folder.
*/
const daffioDocsPathServerFactory = () => join(process.cwd(), environment.docsPath);
const daffioDocsPathServerFactory = () => {
const { error, parsed } = config();
// the SSR runs from the daffio directory and doesn't use dotenv so we rely on cwd
// devs should have the DAFF_ROOT env var set in their .env
return resolve(error || !parsed.DAFF_ROOT ? process.cwd() : resolve(parsed.DAFF_ROOT, 'apps/daffio'), environment.docsPath);
};

/**
* A provider for the docs path for the server.
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"@typescript-eslint/parser": "^6.10.0",
"dgeni": "^0.4.14",
"dgeni-packages": "^0.28.4",
"dotenv": "^16.4.5",
"eslint": "^8.53.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jasmine": "^4.1.3",
Expand Down

0 comments on commit c061885

Please sign in to comment.