diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..95e3ca29c --- /dev/null +++ b/Makefile @@ -0,0 +1,55 @@ +# First off, let's fetch in the executables installed with npm +PATH := node_modules/.bin:$(PATH) + +.PHONY: build + +.PHONY: watch + +build: processjs processcss processhtml processfiles + +watch: watchjs watchcss watchhtml watchfiles + +processjs: + # Compiling TypeScript to JavaScript... + # (according to the configs set in default tsconfig.json) + @tsc + + # This hack is required to make the templates/styles consumable with require() + @for jsfile in `find dist/app -name '*.js'`; do \ + sed -i -r -e "s/templateUrl:\s+('.+')/template: require(\1)/g" $$jsfile; \ + sed -i -r -e "s/styleUrls:\s+\[('.+')\]/styles: \[require(\1).toString()\]/g" $$jsfile; \ + done + +watchjs: + @chokidar --verbose 'src/**/*.ts' -c 'make processjs' + +processcss: + # Compiling LESS to CSS + # @TODO: lesshint report & failOnError + @for lessfile in `find src -name '*.less'`; do \ + csspath="$${lessfile/src/dist}"; \ + cssfile="$${csspath/\.less/\.css}"; \ + lessc --source-map --autoprefix="last 2 versions" $$lessfile $$cssfile; \ + done + +watchcss: + @chokidar --verbose 'src/**/*.less' -c 'make processcss' + +processhtml: + # Copying HTML over to respective paths in dist directory + @for htmlfile in `find src -name '*.html'`; do \ + htmlname=$$(basename $$htmlfile); \ + htmlpath="$${htmlfile/src/dist}"; \ + htmldest="$${htmlpath/$$htmlname/}"; \ + cp $$htmlfile $$htmldest; \ + done + +watchhtml: + @chokidar --verbose 'src/**/*.html' -c 'make processhtml' + +processfiles: + # Copying LICENSE README.adoc & package.json over to dist/ + @cp LICENSE README.adoc package.json dist/ + +watchfiles: + @chokidar --verbose 'LICENSE' 'README.adoc' 'package.json' -c 'make processfiles' diff --git a/package.json b/package.json index d55e57f7c..1c76553a7 100644 --- a/package.json +++ b/package.json @@ -87,6 +87,7 @@ "@ngrx/effects": "^4.1.1", "@ngrx/store": "^4.1.1", "@ngrx/store-devtools": "^4.1.1", + "chokidar-cli": "^1.2.0", "core-js": "^2.5.1", "less-plugin-autoprefix": "^1.5.1", "lodash": "^4.17.4",