Skip to content

Commit 8cc91c4

Browse files
author
Vincent
committed
feat: Add compilerFile for options
1 parent bcee5b9 commit 8cc91c4

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

docs/options.md

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ sidebar: auto
2828

2929
Override the default compiler used to compile `<template>` blocks in single file components.
3030

31+
32+
## compilerFile
33+
34+
- Type: `string`
35+
- default: `undefined`
36+
37+
Supplementary option for `compiler`. Override the default compiler with the compiler in file path, to compile `<template>` blocks in single file components.
38+
3139
## compilerOptions
3240

3341
- type: `Object`

docs/zh/options.md

+8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ sidebar: auto
2828

2929
覆写用来编译单文件组件中 `<template>` 块的默认编译器。
3030

31+
32+
## compilerFile
33+
34+
- 类型:`string`
35+
- 默认值:`undefined`
36+
37+
compiler 参数的替换参数,传入指定编译器的 js 文件路径,覆写用来编译单文件组件中 `<template>` 块的默认编译器。
38+
3139
## compilerOptions
3240

3341
- 类型:`Object`

lib/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let errorEmitted = false
1616

1717
function loadTemplateCompiler (loaderContext) {
1818
try {
19-
return require('vue-template-compiler')
19+
return require(options.compilerFile || 'vue-template-compiler')
2020
} catch (e) {
2121
if (/version mismatch/.test(e.toString())) {
2222
loaderContext.emitError(e)
@@ -66,7 +66,7 @@ module.exports = function (source) {
6666

6767
const descriptor = parse({
6868
source,
69-
compiler: options.compiler || loadTemplateCompiler(loaderContext),
69+
compiler: options.compiler || loadTemplateCompiler(loaderContext, options),
7070
filename,
7171
sourceRoot,
7272
needMap: sourceMap

0 commit comments

Comments
 (0)