diff --git a/scripts/compilation/Inliner.js b/scripts/compilation/Inliner.js index 2d48448764ec..717da9a71716 100644 --- a/scripts/compilation/Inliner.js +++ b/scripts/compilation/Inliner.js @@ -203,7 +203,15 @@ module.exports = class Inliner { .map(() => "..") .join("/")) + "/index.js"; - fs.writeFileSync(file, `module.exports = require("${indexRelativePath}");`); + if (this.isClient) { + fs.rmSync(file); + const files = fs.readdirSync(path.dirname(file)); + if (files.length === 0) { + fs.rmdirSync(path.dirname(file)); + } + } else { + fs.writeFileSync(file, `module.exports = require("${indexRelativePath}");`); + } } return this;