diff --git a/package.json b/package.json index 54847f2..9c6394c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,9 @@ { "name": "theorangeone.net", "version": "1.0.0", - "scripts": {}, + "scripts": { + "build": "node scripts/build.js" + }, "repository": { "type": "git", "url": "git@github:RealOrangeOne/theorangeone.net" @@ -9,11 +11,8 @@ "author": "Jake Howard ", "devDependencies": { "browserify": "14.3.0", - "livereload": "0.6.2", "ncp": "2.0.0", - "node-sass": "4.5.2", - "node-watch": "0.5.2", - "uglifyify": "3.0.4" + "node-sass": "4.5.2" }, "dependencies": { "bootstrap": "4.0.0-alpha.6", diff --git a/scripts/build.js b/scripts/build.js index 29d8819..3b0571b 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -1,65 +1,49 @@ const sass = require('node-sass'); const fs = require('fs'); const path = require('path'); -const watch = require('node-watch'); const browserify = require('browserify'); -const livereload = require('livereload'); const nsp = require('ncp').ncp; -const STATIC = path.join(__dirname, '..', 'static') +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(STATIC, 'src', 'js', 'index.js')], + entries: [path.join(SRC_DIR, 'js', 'index.js')], debug: true, -}) -.transform({ - global: true, - debug: true -}, 'uglifyify'); +}); -const bundle = function () { - b.bundle(function () { - console.log('built js'); - }) - .on('error', console.log) - .pipe(fs.createWriteStream(path.join(STATIC, 'build', 'js', 'app.js'))) -} +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, +}; - -const buildSCSS = function () { - sass.render({ - file: IN_FILE, - outFile: OUT_FILE, - sourceMap: true, - sourceMapEmbed: true, - watch: true, - }, function (error, result) { - if (!error) { - fs.writeFileSync(OUT_FILE, result.css); - console.log("Build CSS"); - } else { - console.log("ERROR", error); - } - }); -} - -nsp('node_modules/font-awesome/fonts', path.join(STATIC, 'build', 'fonts'), function (err) { +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'); }); -bundle(); -buildSCSS(); -// -// watch(path.join(STATIC, 'src', 'js'), {recursive: true}, bundle); -// watch(path.join(STATIC, 'src', 'scss'), {recursive: true}, buildSCSS); -// -// -// livereload.createServer().watch(path.join(STATIC, 'src')); +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"); +});