Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit ef9af70

Browse files
committed
:sparkes: Make script tag optional
Fix #46
1 parent 0bff607 commit ef9af70

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/vueTransform.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,11 @@ function parseTemplate (code) {
161161
}
162162

163163
if (nodes.script.length === 0) {
164-
throw new Error('There must be at least one script tag or one' +
165-
' template tag per *.vue file.')
164+
nodes.script.push({
165+
node: null,
166+
code: 'export default {\n}',
167+
attrs: {}
168+
})
166169
}
167170

168171
return nodes

test/expects/noScript.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var noScript = { template: "<h1>Test</h1>",
2+
};
3+
4+
export default noScript;

test/fixtures/noScript.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<h1>Test</h1>
3+
</template>

0 commit comments

Comments
 (0)