Skip to content

Commit c061885

Browse files
authored
fix(daffio): unable to resolve assets in dev server (#2977)
1 parent 4858161 commit c061885

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DAFF_ROOT=/workspace/daffodil

apps/daffio/README.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@
55
* [Angular CLI](https://cli.angular.io/) - `npm install -g @angular/cli`
66

77
### Getting Started
8-
1. `lerna run build`
9-
2. `ng serve --project=daffio`
10-
3. Navigate to `localhost:4200` in your browser of choice
8+
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`
9+
2. `lerna run build`
10+
3. `ng serve --project=daffio`
11+
4. Navigate to `localhost:4200` in your browser of choice
1112

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

1516
### Contributing to daff.io
16-
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.
17+
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.
1718

18-
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.
19+
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.
1920

2021
> daffio-dev does not support `lint`ing or `build`ing, it only serves the purposes of the internal `@daffodil` development team.
2122

apps/daffio/src/app/docs/services/docs-path-server.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import { Provider } from '@angular/core';
2-
import { join } from 'path';
2+
import { config } from 'dotenv';
3+
import { resolve } from 'path';
34

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

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

1218
/**
1319
* A provider for the docs path for the server.

package-lock.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"@typescript-eslint/parser": "^6.10.0",
7777
"dgeni": "^0.4.14",
7878
"dgeni-packages": "^0.28.4",
79+
"dotenv": "^16.4.5",
7980
"eslint": "^8.53.0",
8081
"eslint-plugin-import": "^2.29.0",
8182
"eslint-plugin-jasmine": "^4.1.3",

0 commit comments

Comments
 (0)