Nested makefile and libraries from CDN
parent
9aea9bc3a8
commit
9393fa73b9
@ -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)"
|
||||
|
@ -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)"
|
@ -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(),
|
||||
],
|
||||
},
|
||||
])
|
||||
|
Loading…
Reference in New Issue