diff --git a/Makefile b/Makefile index dcb5f8d..79d4431 100644 --- a/Makefile +++ b/Makefile @@ -1,37 +1,31 @@ -JS_SOURCES = $(wildcard frontend/src/*.js) -JS_OUTPUTS = $(patsubst frontend/src/%.js, public/js/%.min.js, $(JS_SOURCES)) -SERVER_EXECUTABLE = phc-website-server +GO_SOURCES = $(shell find . -name '*.go') +GO_EXECUTABLE = phc-website-server .PHONY: all all: js go -# -# Build Frontend -# +.PHONY: setup +setup: + mkdir -p public/js .PHONY: js -js: $(JS_OUTPUTS) - @echo "Compiled Frontend" - -public/js/%.min.js: frontend/src/%.js - cd frontend; rollup -c rollup.config.js - mkdir -p public/js - cp $(patsubst frontend/src/%.js, frontend/dist/%.min.js, $<) $@ +js: setup + $(MAKE) -C frontend/ + cp frontend/dist/*.min.js public/js/ # # Build Server # .PHONY: go -go: $(SERVER_EXECUTABLE) +go: $(GO_EXECUTABLE) @echo "Compiled Server" -$(SERVER_EXECUTABLE): - go build -o $(SERVER_EXECUTABLE) . +$(GO_EXECUTABLE): $(GO_SOURCES) + go build -o $(GO_EXECUTABLE) . .PHONY: debug debug: - @echo "JS_SOURCES = $(JS_SOURCES)" - @echo "JS_OUTPUTS = $(JS_OUTPUTS)" - @echo "SERVER_EXECUTABLE = $(SERVER_EXECUTABLE)" + @echo "GO_SOURCES = $(GO_SOURCES)" + @echo "GO_EXECUTABLE = $(GO_EXECUTABLE)" diff --git a/frontend/Makefile b/frontend/Makefile new file mode 100644 index 0000000..3f9bea8 --- /dev/null +++ b/frontend/Makefile @@ -0,0 +1,14 @@ + +JS_SOURCES = src/utenti.js +JS_BUNDLES = $(patsubst src/%.js, dist/%.min.js, $(JS_SOURCES)) + +.PHONY: all +all: $(JS_BUNDLES) + +dist/%.min.js: src/%.js + rollup -c rollup.config.js $< + +.PHONY: debug +debug: + @echo "JS_SOURCES = $(JS_SOURCES)" + @echo "JS_BUNDLES = $(JS_BUNDLES)" \ No newline at end of file diff --git a/frontend/rollup.config.js b/frontend/rollup.config.js index d9663b7..3447719 100644 --- a/frontend/rollup.config.js +++ b/frontend/rollup.config.js @@ -1,15 +1,24 @@ import { defineConfig } from 'rollup' -import { nodeResolve } from '@rollup/plugin-node-resolve' +// import resolve from '@rollup/plugin-node-resolve' import { terser } from 'rollup-plugin-terser' export default defineConfig([ { input: 'src/utenti.js', + external: ['alpinejs', 'fuse.js'], // libraries to not bundle output: { file: 'dist/utenti.min.js', - format: 'es', + format: 'iife', + globals: { + // map library names to global constants + alpinejs: 'Alpine', + 'fuse.js': 'Fuse', + }, }, - plugins: [terser(), nodeResolve()], + plugins: [ + // resolve(), + terser(), + ], }, ]) diff --git a/frontend/src/utenti.js b/frontend/src/utenti.js index b07ac72..7d2e2a5 100644 --- a/frontend/src/utenti.js +++ b/frontend/src/utenti.js @@ -78,5 +78,3 @@ Alpine.data('utenti', () => ({ console.timeEnd('search') }, })) - -Alpine.start() diff --git a/views/utenti.html b/views/utenti.html index f73d01d..48ea477 100644 --- a/views/utenti.html +++ b/views/utenti.html @@ -1,4 +1,9 @@ -{{template "base" .}} {{define "title"}}Utenti • PHC{{end}} {{define "body"}} +{{template "base" .}} +{{define "title"}}Utenti • PHC{{end}} +{{define "body"}} + + +

@@ -51,7 +56,4 @@

- - - {{end}}