From 70c7242d9d2a73e1bb5eb78e16974a6a9aeec0c4 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 17 Jul 2018 23:00:36 +0200 Subject: [PATCH] Fix webpack result test in dist/ When building in production mode, there is no index.js, just an index.min.js.gz. This previously caused unnecessary rebuilds, or even RPM build failures in environments where npm was not available. Test for index.html instead, which is reliable. Also factor this out into a constant to make it easier to adjust in forked projects. --- Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b16b92a..43050ab 100644 --- a/Makefile +++ b/Makefile @@ -7,8 +7,10 @@ export TEST_OS VM_IMAGE=$(CURDIR)/test/images/$(TEST_OS) # one example directory from `npm install` to check if that already ran NODE_MODULES_TEST=node_modules/po2json +# one example file in dist/ from webpack to check if that already ran +WEBPACK_TEST=dist/index.html -all: dist/index.js +all: $(WEBPACK_TEST) # # i18n @@ -60,21 +62,21 @@ dist/po.%.js: po/%.po $(NODE_MODULES_TEST) %.spec: %.spec.in sed -e 's/@VERSION@/$(VERSION)/g' $< > $@ -dist/index.js: $(NODE_MODULES_TEST) $(wildcard src/*) package.json webpack.config.js $(patsubst %,dist/po.%.js,$(LINGUAS)) +$(WEBPACK_TEST): $(NODE_MODULES_TEST) $(wildcard src/*) package.json webpack.config.js $(patsubst %,dist/po.%.js,$(LINGUAS)) NODE_ENV=$(NODE_ENV) npm run build clean: rm -rf dist/ [ ! -e cockpit-$(PACKAGE_NAME).spec.in ] || rm -f cockpit-$(PACKAGE_NAME).spec -install: dist/index.js +install: $(WEBPACK_TEST) mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) cp -r dist/* $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) mkdir -p $(DESTDIR)/usr/share/metainfo/ cp org.cockpit-project.$(PACKAGE_NAME).metainfo.xml $(DESTDIR)/usr/share/metainfo/ # this requires a built source tree and avoids having to install anything system-wide -devel-install: dist/index.js +devel-install: $(WEBPACK_TEST) mkdir -p ~/.local/share/cockpit ln -s `pwd`/dist ~/.local/share/cockpit/$(PACKAGE_NAME)