1
Fork 0

Add basic build script

This commit is contained in:
Jake Howard 2017-04-21 20:06:33 +01:00
parent dcfcca25f0
commit ab5c2042f6
5 changed files with 61 additions and 0 deletions

55
scripts/build.js Normal file
View file

@ -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'));

View file

@ -0,0 +1,2 @@
/*# sourceMappingURL=data:application/json;base64,ewoJInZlcnNpb24iOiAzLAoJImZpbGUiOiAic3R5bGUuY3NzIiwKCSJzb3VyY2VzIjogWwoJCSIuLi8uLi9zcmMvc2Nzcy9zdHlsZS5zY3NzIgoJXSwKCSJuYW1lcyI6IFtdLAoJIm1hcHBpbmdzIjogIiIKfQ== */

4
static/build/js/app.js Normal file
View file

@ -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<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
},{}]},{},[1])
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icm93c2VyLXBhY2svX3ByZWx1ZGUuanMiLCJzdGF0aWMvc3JjL2pzL2luZGV4LmpzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0FDQUE7QUFDQTtBQUNBIiwiZmlsZSI6ImdlbmVyYXRlZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzQ29udGVudCI6WyIoZnVuY3Rpb24gZSh0LG4scil7ZnVuY3Rpb24gcyhvLHUpe2lmKCFuW29dKXtpZighdFtvXSl7dmFyIGE9dHlwZW9mIHJlcXVpcmU9PVwiZnVuY3Rpb25cIiYmcmVxdWlyZTtpZighdSYmYSlyZXR1cm4gYShvLCEwKTtpZihpKXJldHVybiBpKG8sITApO3ZhciBmPW5ldyBFcnJvcihcIkNhbm5vdCBmaW5kIG1vZHVsZSAnXCIrbytcIidcIik7dGhyb3cgZi5jb2RlPVwiTU9EVUxFX05PVF9GT1VORFwiLGZ9dmFyIGw9bltvXT17ZXhwb3J0czp7fX07dFtvXVswXS5jYWxsKGwuZXhwb3J0cyxmdW5jdGlvbihlKXt2YXIgbj10W29dWzFdW2VdO3JldHVybiBzKG4/bjplKX0sbCxsLmV4cG9ydHMsZSx0LG4scil9cmV0dXJuIG5bb10uZXhwb3J0c312YXIgaT10eXBlb2YgcmVxdWlyZT09XCJmdW5jdGlvblwiJiZyZXF1aXJlO2Zvcih2YXIgbz0wO288ci5sZW5ndGg7bysrKXMocltvXSk7cmV0dXJuIHN9KSIsIlxuXG4vLyMgc291cmNlTWFwcGluZ1VSTD1kYXRhOm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