From 966c5cf11127cbddbd624a4b6a0f2a7336716af1 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Sun, 30 Apr 2017 12:02:21 +0100 Subject: [PATCH] use Makefile for build --- Makefile | 30 +++++++++++++++++++++++++++++ circle.yml | 2 +- package.json | 1 - scripts/build.js | 49 ------------------------------------------------ 4 files changed, 31 insertions(+), 51 deletions(-) create mode 100644 Makefile delete mode 100644 scripts/build.js diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..96919b0 --- /dev/null +++ b/Makefile @@ -0,0 +1,30 @@ +BASEDIR=$(PWD) +NODE_BIN=node_modules/.bin + +STATIC_SRC=$(BASEDIR)/static/src +STATIC_BUILD=$(BASEDIR)/static/build +OUTPUT_DIR=$(BASEDIR)/public + + +build: install + rm -rf $(OUTPUT_DIR) + $(NODE_BIN)/browserify $(STATIC_SRC)/js/index.js -o $(STATIC_BUILD)/js/app.js + $(NODE_BIN)/node-sass $(STATIC_SRC)/scss/style.scss $(STATIC_BUILD)/css/style.css --source-map-embed + cp -r $(BASEDIR)/node_modules/font-awesome/fonts $(STATIC_BUILD)/fonts + @hugo -vDEF + + +clean: + rm -rf $(STATIC_BUILD) + rm -rf $(OUTPUT_DIR) + rm -rf $(BASEDIR)/node_modules + + +install: node_modules + @hugo version + +node_modules: + npm install + + +.PHONY: build clean install diff --git a/circle.yml b/circle.yml index 1e1e9ca..4490630 100644 --- a/circle.yml +++ b/circle.yml @@ -8,4 +8,4 @@ dependencies: test: override: - - hugo -vDEF + - make build diff --git a/package.json b/package.json index 9c6394c..d51d9e8 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,6 @@ "author": "Jake Howard ", "devDependencies": { "browserify": "14.3.0", - "ncp": "2.0.0", "node-sass": "4.5.2" }, "dependencies": { diff --git a/scripts/build.js b/scripts/build.js deleted file mode 100644 index 3b0571b..0000000 --- a/scripts/build.js +++ /dev/null @@ -1,49 +0,0 @@ -const sass = require('node-sass'); -const fs = require('fs'); -const path = require('path'); -const browserify = require('browserify'); -const nsp = require('ncp').ncp; - -const STATIC = path.join(__dirname, '..', 'static'); - -const SRC_DIR = path.join(STATIC, 'src'); -const BUILD_DIR = path.join(STATIC, 'build'); - -const OUT_FILE = path.join(STATIC, 'build', 'css', 'style.css'); -const IN_FILE = path.join(STATIC, 'src', 'scss', 'style.scss'); - - -const b = browserify({ - entries: [path.join(SRC_DIR, 'js', 'index.js')], - debug: true, -}); - -const SASS_OPTIONS = { - file: path.join(SRC_DIR, 'scss', 'style.scss'), - outFile: path.join(BUILD_DIR, 'css', 'style.css'), - sourceMap: true, - sourceMapEmbed: true, - watch: true, -}; - -nsp(path.join('node_modules', 'font-awesome', 'fonts'), path.join(BUILD_DIR, 'fonts'), function (err) { - if (err) { - return console.error(err); - } - console.log('Copied fonts'); -}); - -b.bundle(function () { - console.log('built js'); -}) -.on('error', console.error) -.pipe(fs.createWriteStream(path.join(BUILD_DIR, 'js', 'app.js'))) - - -sass.render(SASS_OPTIONS, function (error, result) { - if (error) { - return console.error("ERROR", error); - } - fs.writeFileSync(path.join(BUILD_DIR, 'css', 'style.css'), result.css); - console.log("Build CSS"); -});