选项
include
- 类型:
Array<string|RegExp> | string | RegExp
- 默认:
[/\.vue$/i]
exclude
- 类型:
Array<string|RegExp> | string | RegExp
- 默认:
[]
一个 minimatch 模式或正则表达式,或 minimatch 模式或正则表达式的数组。
defaultLang
- 类型:
{ [key: string]: string }
- 默认:
{}
默认情况下,<script>
是 JavaScript,<style>
是 CSS,<template>
是 HTML,但您可以设置项目的默认值。
例如:defaultLang: { script: 'ts' }
会将默认的 <script>
块语言设置为 typescript。
警告
defaultLang
不会在模板中为您的编辑器/IDE 设置默认语言。
customBlocks
- 类型:
string[] | ((tag: string) => boolean)
- 默认:
() => false
在最终捆绑包中包含/排除自定义块。例如:
...
VuePlugin({
customBlocks: [
'!docs', // exclude <docs>
'gql', // include <gql>
'!*', // exclude everything else
]
})
...
css
- 类型:
boolean
- 默认:
true
在 JavaScript 中注入 CSS。设置 css: false
会将样式提取到 .css
文件中。
data
- 类型:
{ [lang: string]: string | (() => string)}
- 默认:
{}
在 .vue
文件中的 <style>
块中添加内容。
compiler
- 类型: VueTemplateCompiler
- 默认:
require('vue-template-compiler')
覆盖模板解析器。
compilerParseOptions
- 类型: VueTemplateCompilerParseOptions
- 默认:
undefined
sourceRoot
- 类型: string
- 默认:
process.cwd()
style
@vue/component-compiler
选项,用于处理 SFC 中的 <style>
块。
style.postcssOptions
- 类型:
any
- 默认:
undefined
style.postcssPlugins
- 类型:
any[]
- 默认:
undefined
style.postcssCleanOptions
- 类型:
object
- 默认:
{}
提示
要禁用 clean css,请将 style.postcssCleanOptions
设置为 { disabled: true }
style.postcssModulesOptions
类型:
object
默认
{ generateScopedName: '[path][local]-[hash:base64:4]' }
style.preprocessOptions
- 类型:
{ [lang: string]: object }
- 默认:
{}
style.trim
- 类型:
boolean
- 默认:
true
template
@vue/component-compiler
选项,用于处理 SFC 中的 <template>
块。
template.compiler
- 类型:
VueTemplateCompiler
- 默认:
require('vue-template-compiler')
覆盖用于编译单文件组件中 <template>
块的默认编译器。
template.compilerOptions
- 类型:
Object
- 默认:
{}
模板编译器的选项。当使用默认的 vue-template-compiler 时,您可以使用此选项添加自定义编译指令、模块,或使用 { preserveWhitespace: false }
丢弃模板标签之间的空格。
查看 vue-template-compiler
选项参考.
template.transformAssetUrls
类型:
{ [tag: string]: string | Array<string> }
默认
{ video: ['src', 'poster'], source: 'src', img: 'src', image: 'xlink:href' }
在模板编译期间,编译器可以将某些属性(如 src
URL)转换为 require
调用,以便 webpack 可以处理目标资产。例如,<img src="./foo.png">
将尝试在您的文件系统上找到文件 ./foo.png
并将其包含为捆绑包的依赖项。
template.isProduction
- 类型:
boolean
- 默认:
process.env.NODE_ENV === 'production' || process.env.BUILD === 'production'
强制生产模式,这将禁止插件发出仅用于开发的代码。
template.optimizeSSR
- 类型:
boolean
- 默认:
process.env.VUE_ENV === 'server'
启用 Vue 2.4 SSR 编译优化,该优化将渲染函数返回的 vdom 树的一部分编译成纯字符串,从而提高 SSR 性能。在某些情况下,您可能希望明确关闭它,因为生成的渲染函数只能用于 SSR,不能用于客户端渲染或测试。
template.transpileOptions
- 类型:
Object
- 默认:
{}
为生成的渲染函数代码配置 ES2015+ 到 ES5 的转译选项。该 转译器 是 Buble 的一个分支,因此请查看可用的选项 这里.
模板渲染函数编译支持特殊的转换 stripWith
(默认启用),它会删除生成的渲染函数中的 with
使用,使其符合严格模式。
normalizer
- 类型:
string
- 默认:
undefined
styleInjector
- 类型:
string
- 默认:
undefined
styleInjectorSSR
- 类型:
string
- 默认:
undefined
beforeAssemble
(危险)
- 类型:
(descriptor: DescriptorCompileResult) => DescriptorCompileResult
- 默认:
undefined
在 SFC 的块组合在一起之前的钩子。