Personal Website - https://mkr.pw
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

55 lines
976 B

const fs = require('fs')
const browserify = require('browserify')
const babelify = require('babelify')
const sass = require('node-sass')
const watch = require('node-watch')
let jsPath = {
get: './js/main.js',
put: './docs/js/bundle.js'
}
let cssPath = {
get: './sass/style.sass',
put: './docs/css/style.css'
}
const jsfy = () => {
browserify({ debug: true })
.transform(babelify)
.require(jsPath.get, { entry: true })
.bundle()
.on('error', function (err) { console.log('Error: ' + err.message) })
.pipe(fs.createWriteStream(jsPath.put))
}
const cssfy = () => {
sass.render({
file: cssPath.get
}, function (err, result) {
fs.writeFile(cssPath.put, result.css, (e) => {
if (e) console.log(console.log('[ERR] : ' + e))
})
})
}
function start() {
console.log('Running build...')
try {
jsfy()
cssfy()
} catch (e) {
console.log('[ERR] : ' + e)
}
}
start()
watch(['js', 'sass'],
{
recursive: true
},
start
)
console.log('Exiting.')