From 0e863452cce7b938782ad7a8ff243648fb5db6d6 Mon Sep 17 00:00:00 2001 From: happygaijin Date: Tue, 2 Apr 2019 13:22:01 -0700 Subject: [PATCH] MM-14575: Automatically serve static files for plugins (#33) * MM-14575: Automatically serve static files for plugins * Added sample public file * Added HAS_PUBLIC to Makefile to test for public folder * Added "static_files" config setting * MM-14575: Removing static_files from plugin.json * MM14575: Moving public folder to bundle root * MM14575:Moving public directory to root --- Makefile | 3 +++ build/setup.mk | 3 +++ public/hello.html | 1 + 3 files changed, 7 insertions(+) create mode 100644 public/hello.html diff --git a/Makefile b/Makefile index 9c3f70c..4598d52 100644 --- a/Makefile +++ b/Makefile @@ -100,6 +100,9 @@ bundle: ifneq ($(wildcard $(ASSETS_DIR)/.),) cp -r $(ASSETS_DIR) dist/$(PLUGIN_ID)/ endif +ifneq ($(HAS_PUBLIC),) + cp -r public/ dist/$(PLUGIN_ID)/ +endif ifneq ($(HAS_SERVER),) mkdir -p dist/$(PLUGIN_ID)/server/dist; cp -r server/dist/* dist/$(PLUGIN_ID)/server/dist/; diff --git a/build/setup.mk b/build/setup.mk index 90fb163..b3c93a9 100644 --- a/build/setup.mk +++ b/build/setup.mk @@ -25,6 +25,9 @@ HAS_SERVER ?= $(shell build/bin/manifest has_server) # Determine if a webapp is defined in the manifest. HAS_WEBAPP ?= $(shell build/bin/manifest has_webapp) +# Determine if a /public folder is in use +HAS_PUBLIC ?= $(wildcard public/.) + # Try looking for dep in $(GOPATH) in case $(GOPATH)/bin isn't in $(PATH). GOPATH ?= $(shell $(GO) env GOPATH) ifeq ($(DEP),) diff --git a/public/hello.html b/public/hello.html new file mode 100644 index 0000000..9bd0807 --- /dev/null +++ b/public/hello.html @@ -0,0 +1 @@ +Hello from the static files public folder for the com.mattermost.sample-plugin plugin! \ No newline at end of file