Skip to content

Commit

Permalink
Production dotenv (#88)
Browse files Browse the repository at this point in the history
* Add env file creation to build script

* Move env file to central location

* Update dev docs

* Changeset
  • Loading branch information
okaycj authored Oct 29, 2024
1 parent 19ace5b commit 6c42a48
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .changeset/mean-llamas-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lookit/templates": patch
"@lookit/record": patch
"@lookit/data": patch
---

Generate environment file before production build
8 changes: 7 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node: [18, 20]
node: ["18.x", "20.x"]

steps:
- uses: actions/checkout@v4
Expand All @@ -25,6 +25,12 @@ jobs:
- name: Install NPM dependencies
run: npm ci

- name: Create environment file
run: printenv > .env
env:
DEBUG: "false"
LOCAL_DOWNLOAD: "false"

- name: Build packages
run: npm run build

Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,21 @@ npm i @jspsych/config -w @lookit/<name of new package>

## Build all packages

We can use npm workspaces to build all packages.
First, create a `.env` file at the root of the monorepo. It can contain the
following for a successful local development build.

First, install dependencies:
```
DEBUG=true
LOCAL_DOWNLOAD=true
```

Next, we can use npm to install dependencies.

```
npm ci
```

Build all packages:
Then, build all packages.

```
npm run build
Expand Down
2 changes: 1 addition & 1 deletion packages/data/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default makeRollupConfig("chsData").map((config) => {
// Resolve node dependencies to be used in a browser.
nodeResolve({ browser: true, preferBuiltins: false }),
// Add support for .env files
dotenv(),
dotenv({ cwd: "../../" }),
...config.plugins,
],
};
Expand Down
2 changes: 1 addition & 1 deletion packages/record/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default makeRollupConfig("chsRecord").map((config) => {
plugins: [
...config.plugins,
// Add support for .env files
dotenv(),
dotenv({ cwd: "../../" }),
// Add support to import yaml and handlebars files as strings
importAsString({
include: ["**/*.yaml", "**/*.hbs"],
Expand Down
2 changes: 1 addition & 1 deletion packages/templates/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default makeRollupConfig("chsTemplates").map((config) => {
plugins: [
...config.plugins,
// Add support for .env files
dotenv(),
dotenv({ cwd: "../../" }),
// Add support to import yaml and handlebars files as strings
importAsString({
include: ["**/*.yaml", "**/*.hbs"],
Expand Down

0 comments on commit 6c42a48

Please sign in to comment.