KilledByAPixel / LittleJS

LittleJS is a fast HTML5 game engine with many features and no dependencies. 🚂 Choo-Choo!
MIT License
3.19k stars 160 forks source link

feat(build): add node build file #54

Closed ThatOneBro closed 9 months ago

ThatOneBro commented 1 year ago

As mentioned in #46, this PR adds a Node-based build system.

The build system basically works as such:

build
    .addSourceFile("src/engineDebug.js") // adds a source file, files are stitched together in given order
    ...
    .setOutputFile(`build/${ENGINE_NAME}.min.js`) // sets the target output file
    // build steps are executed after the output file has been stitched together and written to disk
    .addBuildStep(closureCompilerStep) 
    .addBuildStep(uglifyBuildStep)
    .addBuildStep((filename) => fs.writeFileSync(`${filename}.sha`, sha256(fs.readFileSync(filename)))) // maybe output a hash of the output?
    .build();

EDIT: Fixed error with closure compiler, everything looks identical to output of original build script now!

Let me know what you think of it overall and definitely open to feedback. Just did this on a whim