Skip to content

Commit

Permalink
Avoid file locks + overwrites by using a temp file for HTML templates
Browse files Browse the repository at this point in the history
This fixes #1331.
  • Loading branch information
developit authored Jul 20, 2020
1 parent deee3c0 commit 044dad6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions packages/cli/lib/lib/webpack/render-html-plugin.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { resolve, join } = require('path');
const os = require('os');
const { existsSync, readFileSync, writeFileSync, mkdirSync } = require('fs');
const HtmlWebpackExcludeAssetsPlugin = require('html-webpack-exclude-assets-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const tempy = require('tempy');
const prerender = require('./prerender');
const createLoadManifest = require('./create-load-manifest');
const { warn } = require('../../util');
Expand Down Expand Up @@ -45,11 +45,8 @@ module.exports = async function(config) {

// Unfortunately html-webpack-plugin expects a true file,
// so we'll create a temporary one.
const tmpDir = join(os.tmpdir(), 'preact-cli');
if (!existsSync(tmpDir)) {
mkdirSync(tmpDir);
}
template = resolve(tmpDir, 'template.tmp.ejs');

template = tempy.file({name: 'template.tmp.ejs'});
writeFileSync(template, content);
}

Expand Down

0 comments on commit 044dad6

Please sign in to comment.