Skip to content

Commit

Permalink
chore(gnoweb): update dev rule to build in a diffierent cache directory
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <[email protected]>
  • Loading branch information
gfanton committed Dec 12, 2024
1 parent 50ab259 commit 0a310bf
Showing 1 changed file with 39 additions and 28 deletions.
67 changes: 39 additions & 28 deletions gno.land/pkg/gnoweb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@
# configurable arguments
DEV_REMOTE ?= 127.0.0.1:26657
CHAIN_ID ?= test3
PUBLIC_DIR ?= public

# Variable Declarations
COMPONENTS_FOLDER := ./components

tools_run := go run -modfile ./tools/go.mod

run_air := $(tools_run) github.com/air-verse/air
run_reflex := $(tools_run) github.com/cespare/reflex

run_logname := go -C ./tools run ./cmd/logname

# css config
input_css := ./frontend/css/input.css
output_css := ./public/styles.css
input_css := frontend/css/input.css
output_css := $(PUBLIC_DIR)/styles.css
tw_version := 3.4.14
tw_config_path := ./frontend/css/tx.config.js
tw_config_path := frontend/css/tx.config.js

# static config
static_folder := ./frontend/static
output_statics := ./public

# Esbuild config
input_js := ./frontend/js/**/*.ts
output_js := ./public/js
static_folder := frontend/static
output_statics := $(PUBLIC_DIR)

# esbuild config
src_dir_js := frontend/js
out_dir_js := $(PUBLIC_DIR)/js
input_js := $(shell find $(src_dir_js) -name '*.ts')
output_js := $(patsubst $(src_dir_js)/%.ts,$(out_dir_js)/%.js,$(input_js))
esbuild_version := 0.24.0

# cache
cache_dir := .cache

#############
# Targets
#############
Expand All @@ -38,12 +39,22 @@ esbuild_version := 0.24.0
# Install dependencies
all: generate

toto:
echo "$(input_js)"
echo "$(output_js)"

# Generate process
generate: clean css ts fonts
css:
npx -y tailwindcss@$(tw_version) -c $(tw_config_path) -i $(input_css) -o $(output_css) --minify # tailwind
ts:
npx -y esbuild $(input_js) --bundle --outdir=$(output_js) --format=esm --minify
generate: css ts fonts

css: $(output_css)
$(output_css): $(input_css)
npx -y tailwindcss@$(tw_version) -c $(tw_config_path) -i $< -o $@ --minify # tailwind
touch $@

ts: $(output_js)
$(out_dir_js)/%.js: $(src_dir_js)/%.ts
npx -y esbuild $< --bundle --outdir=$(out_dir_js) --format=esm --minify

fonts:
mkdir -p $(output_statics)
cp -v -r $(static_folder)/* $(output_statics)
Expand All @@ -60,33 +71,33 @@ fmt:
# Run the development dependencies in parallel
dev:
@echo "-- starting development tools"
@$(MAKE) -j 3 \
PUBLIC_DIR=$(cache_dir)/public $(MAKE) -j 3 \
dev.gnoweb \
dev.ts \
dev.css

# Go server in development mode
dev.gnoweb: | .cache
dev.gnoweb: generate
$(run_reflex) -s -r '.*\.go(html)?' -- \
go run ../../cmd/gnoweb -chainid=${CHAIN_ID} -remote=${DEV_REMOTE} \
2>&1 | $(run_logname) gnoweb

# Tailwind CSS in development mode
dev.css: | public
npx -y tailwindcss@$(tw_version) -c $(tw_config_path) --verbose -i $(input_css) -o $(output_css) --minify --watch \
dev.css: generate | $(PUBLIC_DIR)
npx -y tailwindcss@$(tw_version) -c $(tw_config_path) --verbose -i $(input_css) -o $(output_css) --watch \
2>&1 | $(run_logname) tailwind

# XXX: add versioning on esbuild
# TS in development mode
dev.ts: | public
npx -y esbuild@$(esbuild_version) $(input_js) --bundle --outdir=$(output_js) --format=esm --minify --watch \
dev.ts: generate | $(PUBLIC_DIR)
npx -y esbuild@$(esbuild_version) $(input_js) --bundle --outdir=$(out_dir_js) --format=esm --minify --watch \
2>&1 | $(run_logname) esbuild

# Cleanup
clean:
rm -rf public tmp
rm -rf $(cache_dir) tmp
fclean: clean
rm -rf .cache
rm -rf $(PUBLIC_DIR)

# Dirs
.cache public:; mkdir -p $@
$(PUBLIC_DIR):; mkdir -p $@

0 comments on commit 0a310bf

Please sign in to comment.