Subscribe on changes!

externalRE is not supported automatic http/https prefix url pattern

avatar
Nov 9th 2021

Version

3.2.21

Reproduction link

sfc.vuejs.org/

Steps to reproduce

  1. In template, set an img tag's src with an url with something like "//via.placeholder.com/150":
<template>
  <!-- other stuff -->
  <img src="//via.placeholder.com/150" />
  <!-- other stuff -->
</template>
  1. run vite build

What is expected?

Build process finished successfully.

What is actually happening?

Rollup emit a error with failed to resolve import [img url]


The externalRE is not supported the pattern of automatic http/https prefix by browser.

SFC-compiler took "//via.placeholder.com/150" as a module and raised the error.

const externalRE = /^https?:\/\//

https://github.com/vuejs/vue-next/blob/065c367175c0e93b3cce38d0a031c94c59e570ff/packages/compiler-sfc/src/templateUtils.ts#L9

avatar
Nov 9th 2021

Maybe /^(https?:)?\/\// is better.