Skip to content

Commit

Permalink
fix: add test for vitejs#211
Browse files Browse the repository at this point in the history
  • Loading branch information
rashfael committed Jul 27, 2023
1 parent 93c444c commit ec58d00
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions playground/vue/CustomScriptMacroPlugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { Plugin } from 'vite'

export const vueCustomScriptMacroPlugin: Plugin = {
name: 'vue-custom-cript-macro',
enforce: 'pre',
async transform(code, id) {
return {
code: code.replace(`const count = $ref(foo)`, `const count = ref(foo)`),
map: { mappings: '' },
}
},
}
2 changes: 1 addition & 1 deletion playground/vue/Hmr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Node from './Node.vue'
let foo: number = 0
const count = ref(foo)
const count = $ref(foo)
</script>

<style>
Expand Down
2 changes: 2 additions & 0 deletions playground/vue/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig, splitVendorChunkPlugin } from 'vite'
import vuePlugin from '@vitejs/plugin-vue'
import { vueI18nPlugin } from './CustomBlockPlugin'
import { vueCustomScriptMacroPlugin } from './CustomScriptMacroPlugin'

export default defineConfig({
resolve: {
Expand All @@ -10,6 +11,7 @@ export default defineConfig({
},
},
plugins: [
vueCustomScriptMacroPlugin,
vuePlugin({
reactivityTransform: true,
}),
Expand Down

0 comments on commit ec58d00

Please sign in to comment.