Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: Restart server on file change #848

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ NODE_BIN := $(THIS_DIR)/node_modules/.bin

# applications
NODE ?= node
NODEMON ?= $(NODE_BIN)/nodemon
NPM ?= $(NODE) $(shell which npm)
BUNDLER ?= $(BIN)/bundler
SASS ?= $(NODE_BIN)/node-sass --include-path 'client:shared'
Expand All @@ -35,6 +36,8 @@ CLIENT_CONFIG_FILE := client/config/index.js
NODE_ENV ?= development
CALYPSO_ENV ?= $(NODE_ENV)

SERVER_BUILD_COMMAND ?= $(NODE_BIN)/webpack --display-error-details --config webpack.config.node.js

export NODE_ENV := $(NODE_ENV)
export CALYPSO_ENV := $(CALYPSO_ENV)
export NODE_PATH := server:shared:.
Expand All @@ -53,7 +56,7 @@ install: node_modules

# Simply running `make run` will spawn the Node.js server instance.
run: welcome githooks-commit install build
@$(NODE) build/bundle-$(CALYPSO_ENV).js
@$(NODEMON) --watch server --watch shared --exec "CALYPSO_ENV=$(CALYPSO_ENV) $(SERVER_BUILD_COMMAND); $(NODE)" build/bundle-$(CALYPSO_ENV).js

# a helper rule to ensure that a specific module is installed,
# without relying on a generic `npm install` command
Expand Down Expand Up @@ -111,15 +114,17 @@ public/editor.css: node_modules $(SASS_FILES)
server/devdocs/search-index.js: $(MD_FILES) $(ALL_DEVDOCS_JS)
@$(ALL_DEVDOCS_JS) $(MD_FILES)

build-server: install
builddir:
@mkdir -p build
@CALYPSO_ENV=$(CALYPSO_ENV) $(NODE_BIN)/webpack --display-error-details --config webpack.config.node.js

build-server: install builddir
@CALYPSO_ENV=$(CALYPSO_ENV) $(SERVER_BUILD_COMMAND)

build: install build-$(CALYPSO_ENV)

build-css: public/style.css public/style-rtl.css public/style-debug.css public/editor.css

build-development: build-server $(CLIENT_CONFIG_FILE) server/devdocs/search-index.js build-css
build-development: install builddir $(CLIENT_CONFIG_FILE) server/devdocs/search-index.js build-css

build-wpcalypso: build-server $(CLIENT_CONFIG_FILE) server/devdocs/search-index.js build-css
@$(BUNDLER)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
"mocha": "2.3.4",
"mockery": "1.4.0",
"nock": "2.17.0",
"nodemon": "1.8.1",
"react-hot-loader": "1.3.0",
"rewire": "2.3.3",
"sinon": "1.12.2",
Expand Down