Skip to content

Commit cdd4922

Browse files
authored
fix(plugin-vue): support external import URLs for monorepos (#524)
1 parent 15c0eb0 commit cdd4922

File tree

14 files changed

+102
-0
lines changed

14 files changed

+102
-0
lines changed

packages/plugin-vue/src/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,10 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin<Api> {
387387
getTempSrcDescriptor(filename, query)
388388
: getDescriptor(filename, options.value)!
389389

390+
if (query.src) {
391+
this.addWatchFile(filename)
392+
}
393+
390394
if (query.type === 'template') {
391395
return transformTemplateAsModule(
392396
code,
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<style src="/#external/src-import/style.css" scoped></style>
2+
<style src="/#external/src-import/style2.css" scoped></style>
3+
<template src="./template.html"></template>
4+
<script src="./script.ts"></script>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.one {
2+
background: yellow;
3+
}
4+
5+
.two {
6+
border: solid 1px red;
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { defineComponent } from 'vue'
2+
import SrcImportStyle from './srcImportStyle.vue'
3+
import SrcImportStyle2 from './srcImportStyle2.vue'
4+
import SrcImportModuleStyle from './srcImportModuleStyle.vue'
5+
import SrcImportModuleStyle2 from './srcImportModuleStyle2.vue'
6+
7+
export default defineComponent({
8+
components: {
9+
SrcImportStyle,
10+
SrcImportStyle2,
11+
SrcImportModuleStyle,
12+
SrcImportModuleStyle2,
13+
},
14+
setup() {
15+
return {
16+
msg: 'hello from script src!',
17+
}
18+
},
19+
})
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<template>
2+
<div :class="$style.one">src for import css module</div>
3+
</template>
4+
<style lang="scss" module src="/#external/src-import/css.module.css" />
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<template>
2+
<div :class="$style.two">src for import css module</div>
3+
</template>
4+
<style lang="scss" module src="/#external/src-import/css.module.css" />
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<style src="/#external/src-import/style.css" scoped></style>
2+
<template>
3+
<div class="src-imports-script">{{ msg }}</div>
4+
</template>
5+
<script setup>
6+
const msg = 'hello from component A!'
7+
</script>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<style src="/#external/src-import/style2.css" scoped></style>
2+
<template>
3+
<div class="src-imports-style">This should be tan</div>
4+
</template>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.external-src-imports-style {
2+
color: tan;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.external-src-imports-script {
2+
color: #0088ff;
3+
}

0 commit comments

Comments
 (0)