Skip to content

Commit

Permalink
Enable standalone builds
Browse files Browse the repository at this point in the history
  • Loading branch information
m0ar committed Jul 12, 2023
1 parent 3db671c commit 782e0d8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@ NODES_ABS=$(realpath $(NODES_DIR))
.PHONY: build
build: .env install nodes

.PHONY: standalone
standalone: .env clean install
# For clarity: depends on the "clean" target to wipe any local linking
# Stub contracts to allow building without desci-contracts
./stubContract.sh

.PHONY: nodes
nodes:
$(MAKE) -C $(NODES_DIR) build
yarn link @desci-labs/desci-models

# Cleanup potential leftover actual directories from standalone build
rm -rf src/desci-contracts-*

# Link contract artifacts to this project.
# -s symlink
# -f overwrite (so we can re-build against a different contract repo version)
# -T treat target as a file (otherwise it will nest in an existing dir link)
ln -sfT $(NODES_ABS)/desci-contracts/artifacts src/desci-contracts-artifacts
ln -sfT $(NODES_ABS)/desci-contracts/.openzeppelin src/desci-contracts-config
ln -sT $(NODES_ABS)/desci-contracts/artifacts src/desci-contracts-artifacts
ln -sT $(NODES_ABS)/desci-contracts/.openzeppelin src/desci-contracts-config


.PHONY: install
Expand All @@ -26,10 +35,12 @@ install:
clean:
rm -rf node_modules
rm -rf build

# Unlinking desci-models (may fail if not present, that's okay)
yarn unlink @desci-labs/desci-models || true

# Clean up symlinks
rm -f src/desci-contracts-*
rm -rf src/desci-contracts-*

.PHONY: .env
.env:
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ export NODES_DIR=path/to/nodes
yarn start
```

## Standalone build
To work on the frontend standalone, without depending on any local dependencies, you can use these commands:
```bash
yarn start:standalone
yarn build:standalone
```

# Bundling
This project uses create-react-app and is not ejected. Webpack config is handled by [CRACO](https://github.com/gsoft-inc/craco).

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"scripts": {
"analyze": "source-map-explorer 'build/static/js/*.js'",
"start": "make && REACT_APP_VERSION=$npm_package_version TAILWIND_MODE=watch craco start",
"start:standalone": "make standalone && REACT_APP_VERSION=$npm_package_version TAILWIND_MODE=watch craco start",
"build": "make && REACT_APP_VERSION=$npm_package_version GENERATE_SOURCEMAP=false craco build && yarn terser",
"build:standalone": "make standalone && REACT_APP_VERSION=$npm_package_version GENERATE_SOURCEMAP=false craco build && yarn terser",
"test": "craco test",
"eject": "react-scripts eject",
"terser": "terser ./build/static/js/*.js -c -m --mangle-props regex=/_$/",
Expand Down

0 comments on commit 782e0d8

Please sign in to comment.