Skip to content

Commit 483cb50

Browse files
author
Sergii Naumov
committed
Enable src attr for script tag
1 parent 765d85d commit 483cb50

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

lib/loader.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,15 @@ module.exports = function (content) {
153153
})
154154

155155
// add require for script
156+
var script
156157
if (parts.script.length) {
158+
script = parts.script[0]
157159
output +=
158-
'module.exports = ' + getRequire('script', parts.script[0], 0) + '\n' +
159-
'if (module.exports.__esModule) module.exports = module.exports.default\n'
160+
'module.exports = ' + (
161+
script.src
162+
? getRequireForImport('script', script, 0)
163+
: getRequire('script', script, 0)
164+
) + '\nif (module.exports.__esModule) module.exports = module.exports.default\n'
160165
}
161166

162167
// add require for template

lib/parser.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,6 @@ module.exports = function (content) {
3232

3333
// handle src imports
3434
if (src) {
35-
if (type !== 'style' && type !== 'template') {
36-
return cb(new Error(
37-
'[vue-loader] src import is only supported for <template> and <style> tags.'
38-
))
39-
}
4035
if (type === 'style') {
4136
output.styleImports.push({
4237
src: src,
@@ -48,6 +43,11 @@ module.exports = function (content) {
4843
src: src,
4944
lang: lang
5045
})
46+
} else if (type === 'script') {
47+
output.script.push({
48+
src: src,
49+
lang: lang
50+
})
5151
}
5252
return
5353
}

0 commit comments

Comments
 (0)