Skip to content

Commit

Permalink
fix: vite json parser error, close #166
Browse files Browse the repository at this point in the history
vite json plugin throw error when route block has [lang=json]
  • Loading branch information
hannoeru committed Feb 14, 2022
1 parent 771e956 commit 95e4a58
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions examples/vue/src/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@
</div>
</template>

<route>
<route lang="json">
{
name: "homepage",
meta: {requiresAuth: false}
"name": "homepage",
"meta": {
"requiresAuth": false
}
}
</route>
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function pagesPlugin(userOptions: UserOptions = {}): Plugin {
async transform(_code, id) {
if (!/vue&type=route/.test(id)) return
return {
code: 'export default {};',
code: id.endsWith('lang.json') ? '{}' : 'export default {};',
map: null,
}
},
Expand Down

0 comments on commit 95e4a58

Please sign in to comment.