From 1fa4d9a32d987bf3c83fdb3e681b1e748b2375fb Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 2 Jul 2020 14:03:48 -0400 Subject: [PATCH] fix(build/css): properly handle css linked in index.html for build --- src/node/build/buildPluginHtml.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/node/build/buildPluginHtml.ts b/src/node/build/buildPluginHtml.ts index 7079a11db61130..00bc165f007c6e 100644 --- a/src/node/build/buildPluginHtml.ts +++ b/src/node/build/buildPluginHtml.ts @@ -1,7 +1,7 @@ import { Plugin, RollupOutput, OutputChunk } from 'rollup' import path from 'path' import fs from 'fs-extra' -import { isExternalUrl, cleanUrl, isStaticAsset } from '../utils/pathUtils' +import { isExternalUrl, cleanUrl } from '../utils/pathUtils' import { resolveAsset } from './buildPluginAsset' import { parse as Parse, @@ -182,8 +182,10 @@ const compileHtml = async ( !isExternalUrl(p.value.content) ) { const url = cleanUrl(p.value.content) - js += `\nimport ${JSON.stringify(url)}` - if (isStaticAsset(url)) { + if (url.endsWith('.css')) { + js += `\nimport ${JSON.stringify(url)}` + s.remove(node.loc.start.offset, node.loc.end.offset) + } else { assetUrls.push(p) } }