Files
minecraft-data/buildBundle.js

26 lines
948 B
JavaScript

const fs = require('fs')
const browserify = require('browserify')
const through = require('through')
const blockedFiles = ['steve.json', 'blockMappings.json', 'blockCollisionShapes.json', 'blocksJ2B.json', 'blocksB2J.json', 'blocks_models.json', 'blocks_states.json', 'entityLoot.json', 'blockLoot.json', 'language.json', 'blockStates.json', 'commands.json']
const stubs = { 'blockCollisionShapes.json': '{"blocks":{},"shapes":{}}' }
const bundle = fs.createWriteStream('bundle.js')
const bundler = browserify()
bundler.transform(function (file, options) {
for (const blockedFile of blockedFiles) {
if (file.endsWith(blockedFile)) {
console.log('Blocked', file)
return through(function write () {
// no op
}, function end () {
this.queue(stubs[blockedFile] || '[]')
this.queue(null)
})
}
}
return through()
}, { global: true })
bundler.add('./index.js')
bundler.bundle().pipe(bundle)