Added customizable input and output folder for builder

master
Guusvanmeerveld 3 years ago
parent 9098d7952e
commit 414fefd0fa

@ -1,4 +1,6 @@
module.exports = {
root: 'src',
out: 'dist',
paths: {
"@stylesheets": "css",
"@scripts": "js",

@ -1,11 +1,11 @@
const { join } = require('path');
const fs = require('fs-extra');
const srcDir = join(process.cwd(), 'src');
const distDir = join(process.cwd(), 'dist');
const config = require(join(process.cwd(), 'builder.config.js'));
const srcDir = join(process.cwd(), config.root);
const distDir = join(process.cwd(), config.out);
const { builder } = require('./builders');
if (config.interpreter) {

@ -3,10 +3,10 @@ const { join } = require('path');
const { fileBuilder } = require('./builders');
const { interpreter } = require(join(process.cwd(), 'builder.config.js'));
const config = require(join(process.cwd(), 'builder.config.js'));
const srcDir = join(process.cwd(), 'src');
const distDir = join(process.cwd(), 'dist');
const srcDir = join(process.cwd(), config.root);
const distDir = join(process.cwd(), config.out);
const watcher = chokidar.watch(srcDir, {
persistent: true,
@ -20,12 +20,11 @@ watcher.on('change', async (path) => {
splittedPath.pop();
const conf = config.interpreter.find((conf) => conf.input == (splittedPath.join('/') || '.'));
const config = interpreter.find((conf) => conf.input == (splittedPath.join('/') || '.'));
if (config) {
if (conf) {
const fileType = path.split('.').pop();
const outPath = join(distDir, config.output);
const outPath = join(distDir, conf.output);
await fileBuilder(path, outPath, fileType);
}

Loading…
Cancel
Save