From ab5c2042f6927968ce959d204b9f920431958aa7 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Fri, 21 Apr 2017 20:06:33 +0100 Subject: [PATCH] Add basic build script --- scripts/build.js | 55 ++++++++++++++++++++++++++++++++++++++ static/build/css/style.css | 2 ++ static/build/js/app.js | 4 +++ static/src/js/index.js | 0 static/src/scss/style.scss | 0 5 files changed, 61 insertions(+) create mode 100644 scripts/build.js create mode 100644 static/build/css/style.css create mode 100644 static/build/js/app.js create mode 100644 static/src/js/index.js create mode 100644 static/src/scss/style.scss diff --git a/scripts/build.js b/scripts/build.js new file mode 100644 index 0000000..81c1d15 --- /dev/null +++ b/scripts/build.js @@ -0,0 +1,55 @@ +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 STATIC = path.join(__dirname, '..', 'static') + +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')], + 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 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"); + } + }); +} + +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')); diff --git a/static/build/css/style.css b/static/build/css/style.css new file mode 100644 index 0000000..cda8913 --- /dev/null +++ b/static/build/css/style.css @@ -0,0 +1,2 @@ + +/*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAic3R5bGUuY3NzIiwKCSJzb3VyY2VzIjogWwoJCSIuLi8uLi9zcmMvc2Nzcy9zdHlsZS5zY3NzIgoJXSwKCSJuYW1lcyI6IFtdLAoJIm1hcHBpbmdzIjogIiIKfQ== */ \ No newline at end of file diff --git a/static/build/js/app.js b/static/build/js/app.js new file mode 100644 index 0000000..0b78940 --- /dev/null +++ b/static/build/js/app.js @@ -0,0 +1,4 @@ +(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o