use Makefile for build
This commit is contained in:
parent
080256df66
commit
966c5cf111
4 changed files with 31 additions and 51 deletions
30
Makefile
Normal file
30
Makefile
Normal file
|
@ -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
|
|
@ -8,4 +8,4 @@ dependencies:
|
|||
|
||||
test:
|
||||
override:
|
||||
- hugo -vDEF
|
||||
- make build
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
"author": "Jake Howard <git@theorangeone.net>",
|
||||
"devDependencies": {
|
||||
"browserify": "14.3.0",
|
||||
"ncp": "2.0.0",
|
||||
"node-sass": "4.5.2"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
@ -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");
|
||||
});
|
Loading…
Reference in a new issue