diff --git a/.changeset/healthy-toys-heal.md b/.changeset/healthy-toys-heal.md new file mode 100644 index 000000000..6d7c3c946 --- /dev/null +++ b/.changeset/healthy-toys-heal.md @@ -0,0 +1,5 @@ +--- +'preact-cli': patch +--- + +On project create, the CLI won't copy the HTML template or the service worker when the source template is a widget diff --git a/packages/cli/lib/commands/create.js b/packages/cli/lib/commands/create.js index ab412b6da..7d4a73745 100644 --- a/packages/cli/lib/commands/create.js +++ b/packages/cli/lib/commands/create.js @@ -383,18 +383,23 @@ async function command(repo, dest, argv) { const sourceDirectory = join(resolve(cwd, dest), 'src'); - // Copy over template.html - const templateSrc = resolve( - __dirname, - join('..', 'resources', 'template.html') - ); - const templateDest = join(sourceDirectory, 'template.html'); - await copyFileToDestination(templateSrc, templateDest); + if (!repo.includes('widget')) { + // Copy over template.html + const templateSrc = resolve( + __dirname, + join('..', 'resources', 'template.html') + ); + const templateDest = join(sourceDirectory, 'template.html'); + await copyFileToDestination(templateSrc, templateDest); - // Copy over sw.js - const serviceWorkerSrc = resolve(__dirname, join('..', '..', 'sw', 'sw.js')); - const serviceWorkerDest = join(sourceDirectory, 'sw.js'); - await copyFileToDestination(serviceWorkerSrc, serviceWorkerDest); + // Copy over sw.js + const serviceWorkerSrc = resolve( + __dirname, + join('..', '..', 'sw', 'sw.js') + ); + const serviceWorkerDest = join(sourceDirectory, 'sw.js'); + await copyFileToDestination(serviceWorkerSrc, serviceWorkerDest); + } if (argv.install) { spinner.text = 'Installing dependencies:\n';