Skip to content

Commit f42350c

Browse files
committed
feat(src): Add support of template and script src tags
Close #28
1 parent 30506cc commit f42350c

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/process.js

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ const compileBabel = require('./compilers/babel-compiler')
77
const compileTypescript = require('./compilers/typescript-compiler')
88
const compileCoffeeScript = require('./compilers/coffee-compiler')
99
const extractPropsFromFunctionalTemplate = require('./extract-props')
10+
const fs = require('fs')
11+
const join = require('path').join
1012

1113
const splitRE = /\r?\n/g
1214

@@ -41,6 +43,10 @@ module.exports = function (src, path) {
4143

4244
changePartsIfFunctional(parts)
4345

46+
if (parts.script && parts.script.src) {
47+
parts.script.content = fs.readFileSync(join(path, '..', parts.script.src), 'utf8')
48+
}
49+
4450
const result = processScript(parts.script)
4551
const script = result.code
4652
const inputMap = result.sourceMap
@@ -53,6 +59,10 @@ module.exports = function (src, path) {
5359
': module.exports)\n'
5460

5561
if (parts.template) {
62+
if (parts.template.src) {
63+
parts.template.content = fs.readFileSync(join(path, '..', parts.template.src), 'utf8')
64+
}
65+
5666
const renderFunctions = compileTemplate(parts.template)
5767

5868
output += '__vue__options__.render = ' + renderFunctions.render + '\n' +

0 commit comments

Comments
 (0)