-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactors build to use import instead of require and switch to esbuil…
…d for bundling scripts
- Loading branch information
Showing
14 changed files
with
893 additions
and
4,715 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as esbuild from 'esbuild'; | ||
|
||
const args = process.argv.slice(2); | ||
|
||
console.log('build type: ', args[0]); | ||
|
||
if (args[0] === 'js') { | ||
let ctx = await esbuild.context({ | ||
entryPoints: ['app/resources/js/main.ts'], | ||
bundle: true, | ||
outfile: 'public/resources/js/bundle.js', | ||
}); | ||
|
||
if (args[1] === 'watch') { | ||
await ctx.watch(); | ||
} else { | ||
ctx.rebuild(); | ||
} | ||
} | ||
|
||
/* | ||
if (args[0] === 'css') { | ||
let ctxcss = await esbuild.context({ | ||
entryPoints: ['app/resources/css/styles.css'], | ||
bundle: true, | ||
loader: { | ||
'.svg': 'dataurl', | ||
'.ttf': 'copy' | ||
}, | ||
outfile: 'public/resources/css/styles.css', | ||
}); | ||
if (args[1] === 'watch') { | ||
await ctxcss.watch(); | ||
console.log('watching css...'); | ||
} | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
const fs = require('fs'); | ||
const content = fs.readFileSync("projectConfig.json"); | ||
module.exports = JSON.parse(content); | ||
import * as fs from 'fs'; | ||
const content = fs.readFileSync('projectConfig.json'); | ||
export default JSON.parse(content); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,40 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const handlebars = require('handlebars'); | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import Handlebars from "handlebars"; | ||
|
||
module.exports = { | ||
// https://stackoverflow.com/questions/50121881/node-js-recursively-list-full-path-of-files | ||
traverseDir: (dir, callback) => { | ||
const myRecursiveFunction = function(dir, callback) { | ||
fs.readdirSync(dir).forEach(file => { | ||
const fullPath = path.join(dir, file); | ||
if (fs.lstatSync(fullPath).isDirectory()) { | ||
myRecursiveFunction(fullPath, callback); | ||
} else { | ||
callback(fullPath); | ||
} | ||
}); | ||
}; | ||
|
||
myRecursiveFunction(dir, callback); | ||
}, | ||
registerHandlebarsHelpers: () => { | ||
/* taken from: https://stackoverflow.com/a/31632215/884177 */ | ||
handlebars.registerHelper({ | ||
eq: (v1, v2) => v1 === v2, | ||
ne: (v1, v2) => v1 !== v2, | ||
lt: (v1, v2) => v1 < v2, | ||
gt: (v1, v2) => v1 > v2, | ||
lte: (v1, v2) => v1 <= v2, | ||
gte: (v1, v2) => v1 >= v2, | ||
and() { | ||
return Array.prototype.every.call(arguments, Boolean); | ||
}, | ||
or() { | ||
return Array.prototype.slice.call(arguments, 0, -1).some(Boolean); | ||
// https://stackoverflow.com/questions/50121881/node-js-recursively-list-full-path-of-files | ||
const traverseDir = (dir, callback) => { | ||
const myRecursiveFunction = function(dir, callback) { | ||
fs.readdirSync(dir).forEach(file => { | ||
const fullPath = path.join(dir, file); | ||
if (fs.lstatSync(fullPath).isDirectory()) { | ||
myRecursiveFunction(fullPath, callback); | ||
} else { | ||
callback(fullPath); | ||
} | ||
}); | ||
} | ||
} | ||
}; | ||
|
||
myRecursiveFunction(dir, callback); | ||
}; | ||
|
||
const registerHandlebarsHelpers = () => { | ||
/* taken from: https://stackoverflow.com/a/31632215/884177 */ | ||
Handlebars.registerHelper({ | ||
eq: (v1, v2) => v1 === v2, | ||
ne: (v1, v2) => v1 !== v2, | ||
lt: (v1, v2) => v1 < v2, | ||
gt: (v1, v2) => v1 > v2, | ||
lte: (v1, v2) => v1 <= v2, | ||
gte: (v1, v2) => v1 >= v2, | ||
and() { | ||
return Array.prototype.every.call(arguments, Boolean); | ||
}, | ||
or() { | ||
return Array.prototype.slice.call(arguments, 0, -1).some(Boolean); | ||
} | ||
}); | ||
}; | ||
|
||
export {traverseDir, registerHandlebarsHelpers}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.