Skip to content

Commit

Permalink
[CE-35] #time 3h 13m #comment Auto build for react
Browse files Browse the repository at this point in the history
Add auto build react js when start react THEME,
Auto clean json.tgz after build react js.

Change-Id: I4627a9469de6ce2b8b301c18f6c655a329981611
Signed-off-by: Haitao Yue <hightall@me.com>
  • Loading branch information
hightall committed Jun 25, 2017
1 parent 823ce0f commit 8f3a042
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
STATIC_FOLDER=themes/basic/static
TEMPLATE_FOLDER=themes/basic/templates
TEMPLATE_FOLDER=themes/basic/templates
NPM_REGISTRY=
20 changes: 19 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,30 @@ RESET := $(shell tput -Txterm sgr0)
THEME?=basic
STATIC_FOLDER?=themes\/${THEME}\/static
TEMPLATE_FOLDER?=themes\/${THEME}\/templates
NPM_REGISTRY?=registry.npmjs.org
SYSTEM=$(shell uname)
ifeq ($(SYSTEM), Darwin)
SED = sed -ix
else
SED = sed -i
endif

ifeq (${THEME}, react)
ifneq ($(wildcard ./src/themes/react/static/node_modules),)
INSTALL_NPM=
else
INSTALL_NPM=npm-install
endif
ifneq ($(wildcard ./src/themes/react/static/js/dist),)
BUILD_JS=
else
BUILD_JS=build-js
endif
START_OPTIONS = initial-env $(INSTALL_NPM) $(BUILD_JS)
else
START_OPTIONS = initial-env
endif

.PHONY: \
all \
check \
Expand Down Expand Up @@ -53,9 +70,10 @@ redeploy: ##@Service Redeploy single service, Use like "make redeploy service=da
initial-env: ##@Configuration Initial Configuration for dashboard
$(SED) 's/\(STATIC_FOLDER=\).*/\1${STATIC_FOLDER}/' .env
$(SED) 's/\(TEMPLATE_FOLDER=\).*/\1${TEMPLATE_FOLDER}/' .env
$(SED) 's/\(NPM_REGISTRY=\).*/\1${NPM_REGISTRY}/' .env

start: ##@Service Start service
@$(MAKE) initial-env
@$(MAKE) $(START_OPTIONS)
bash scripts/start.sh

stop: ##@Service Stop service
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-build-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ services:
container_name: build-js
volumes: # This should be removed in product env
- ./src/themes/react/static:/app
command: bash -c "cd /app && npm run build"
command: bash -c "cd /app && npm run build && rm -rf *.json.gz"
4 changes: 3 additions & 1 deletion docker-compose-npm-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ services:
container_name: npm-install
volumes: # This should be removed in product env
- ./src/themes/react/static:/app
command: bash -c "cd /app && npm install --loglevel http"
environment:
- NPM_REGISTRY=$NPM_REGISTRY
command: bash -c "cd /app && npm install --loglevel http --registry https://$NPM_REGISTRY"

0 comments on commit 8f3a042

Please sign in to comment.