Skip to content

Commit

Permalink
Use webpack asset system instead of manually writing file (jamiebuild…
Browse files Browse the repository at this point in the history
…s#132)

* Remove synchronous file write

* Remove unneeded options
  • Loading branch information
timneutkens authored Feb 28, 2020
1 parent 4e34a7f commit 8392325
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/webpack.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use strict';
const fs = require('fs');
const path = require('path');
const url = require('url');

function buildManifest(compiler, compilation) {
Expand Down Expand Up @@ -39,15 +37,14 @@ class ReactLoadablePlugin {
compiler.plugin('emit', (compilation, callback) => {
const manifest = buildManifest(compiler, compilation);
var json = JSON.stringify(manifest, null, 2);
const outputDirectory = path.dirname(this.filename);
try {
fs.mkdirSync(outputDirectory);
} catch (err) {
if (err.code !== 'EEXIST') {
throw err;
compilation.assets[this.filename] = {
source() {
return json;
},
size() {
return json.length
}
}
fs.writeFileSync(this.filename, json);
callback();
});
}
Expand Down

0 comments on commit 8392325

Please sign in to comment.