From 2b6237b110cdcc4b2b3808fa0da63a72ac2fd928 Mon Sep 17 00:00:00 2001 From: aelbore Date: Mon, 4 May 2020 21:37:01 +0800 Subject: [PATCH 1/2] when setting buildOptions.write to false output style.css should not be write to ./dist/style.css --- src/node/build.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/node/build.ts b/src/node/build.ts index a03005e2b92c91..95782fc9fd2769 100644 --- a/src/node/build.ts +++ b/src/node/build.ts @@ -161,13 +161,15 @@ export async function build(options: BuildOptions = {}): Promise { } } else if (emitAssets) { // write asset - const filepath = path.join(resolvedAssetsPath, chunk.fileName) - !silent && - console.log( - `write ${chalk.magenta(path.relative(process.cwd(), filepath))}` - ) - await fs.mkdir(path.dirname(filepath), { recursive: true }) - await fs.writeFile(filepath, chunk.source) + if (write) { + const filepath = path.join(resolvedAssetsPath, chunk.fileName) + !silent && + console.log( + `write ${chalk.magenta(path.relative(process.cwd(), filepath))}` + ) + await fs.mkdir(path.dirname(filepath), { recursive: true }) + await fs.writeFile(filepath, chunk.source) + } } } From 843fc736c36194fe1b77ab6f65a0375cb3acbf19 Mon Sep 17 00:00:00 2001 From: Evan You Date: Mon, 4 May 2020 10:59:37 -0400 Subject: [PATCH 2/2] Update build.ts --- src/node/build.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/node/build.ts b/src/node/build.ts index 95782fc9fd2769..69326607b04d90 100644 --- a/src/node/build.ts +++ b/src/node/build.ts @@ -159,17 +159,15 @@ export async function build(options: BuildOptions = {}): Promise { await fs.mkdir(path.dirname(filepath), { recursive: true }) await fs.writeFile(filepath, chunk.code) } - } else if (emitAssets) { + } else if (emitAssets && write) { // write asset - if (write) { - const filepath = path.join(resolvedAssetsPath, chunk.fileName) - !silent && - console.log( - `write ${chalk.magenta(path.relative(process.cwd(), filepath))}` - ) - await fs.mkdir(path.dirname(filepath), { recursive: true }) - await fs.writeFile(filepath, chunk.source) - } + const filepath = path.join(resolvedAssetsPath, chunk.fileName) + !silent && + console.log( + `write ${chalk.magenta(path.relative(process.cwd(), filepath))}` + ) + await fs.mkdir(path.dirname(filepath), { recursive: true }) + await fs.writeFile(filepath, chunk.source) } }