diff --git a/src/node/build.ts b/src/node/build.ts index 2474c8619ad237..4468340941fb95 100644 --- a/src/node/build.ts +++ b/src/node/build.ts @@ -11,9 +11,8 @@ import resolve from 'resolve-from' import chalk from 'chalk' import { Resolver, createResolver } from './resolver' import { Options } from 'rollup-plugin-vue' -import { scriptRE } from './utils' import { createBuildResolvePlugin } from './buildPluginResolve' -import { createBuildHtmlPlugin } from './buildPluginHtml' +import { createBuildHtmlPlugin, scriptRE } from './buildPluginHtml' import { createBuildCssPlugin } from './buildPluginCss' import { createBuildAssetPlugin } from './buildPluginAsset' diff --git a/src/node/buildPluginHtml.ts b/src/node/buildPluginHtml.ts index 74b4eadcacfb7f..c10d4bd186ec97 100644 --- a/src/node/buildPluginHtml.ts +++ b/src/node/buildPluginHtml.ts @@ -1,5 +1,7 @@ import { Plugin } from 'rollup' -import { scriptRE } from './utils' + +export const scriptRE = /]*)>([\s\S]*?)<\/script>/gm +const srcRE = /\bsrc=(?:"([^"]+)"|'([^']+)'|([^'"\s]+)\b)/ export const createBuildHtmlPlugin = ( indexPath: string, @@ -12,9 +14,18 @@ export const createBuildHtmlPlugin = ( let script = '' let match while ((match = scriptRE.exec(indexContent))) { - // TODO handle + // add its content + script += match[2] } return script } diff --git a/src/node/utils.ts b/src/node/utils.ts index 138ecd7aa45cab..39a02b35b25651 100644 --- a/src/node/utils.ts +++ b/src/node/utils.ts @@ -4,8 +4,6 @@ import LRUCache from 'lru-cache' import os from 'os' import { Context } from 'koa' -export const scriptRE = /]*>([\s\S]*?)<\/script>/gm - const imageRE = /\.(png|jpe?g|gif|svg)(\?.*)?$/ const mediaRE = /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/ const fontsRE = /\.(woff2?|eot|ttf|otf)(\?.*)?$/i