@@ -4,6 +4,7 @@ import parse5 from 'parse5'
4
4
import validateTemplate from 'vue-template-validator'
5
5
import transpileVueTemplate from 'vue-template-es2015-compiler'
6
6
import { compile } from './style/index'
7
+ import templateProcessor from './template/index'
7
8
import { relative } from 'path'
8
9
import MagicString from 'magic-string'
9
10
import debug from './debug'
@@ -111,11 +112,15 @@ function injectTemplate (script, template, lang, options, modules) {
111
112
/**
112
113
* Compile template: DeIndent and minify html.
113
114
*/
114
- function processTemplate ( source , id , content , options ) {
115
+ async function processTemplate ( source , id , content , options , nodes , modules ) {
115
116
if ( source === undefined ) return undefined
116
117
117
118
const { code } = source
118
- const template = deIndent ( code )
119
+ const template = deIndent (
120
+ await ( options . disableCssModuleStaticReplacement !== true
121
+ ? templateProcessor ( code , { modules } , options )
122
+ : code )
123
+ )
119
124
120
125
if ( ! options . compileTemplate ) {
121
126
const warnings = validateTemplate ( code , content )
@@ -130,8 +135,8 @@ function processTemplate (source, id, content, options) {
130
135
return htmlMinifier . minify ( template , options . htmlMinifier )
131
136
}
132
137
133
- function processScript ( source , id , content , options , nodes , modules ) {
134
- const template = processTemplate ( nodes . template [ 0 ] , id , content , options , nodes , modules )
138
+ async function processScript ( source , id , content , options , nodes , modules ) {
139
+ const template = await processTemplate ( nodes . template [ 0 ] , id , content , options , nodes , modules )
135
140
136
141
const lang = source . attrs . lang || 'js'
137
142
@@ -235,7 +240,7 @@ export default async function vueTransform (code, id, options) {
235
240
const nodes = parseTemplate ( code )
236
241
const css = await processStyle ( nodes . style , id , code , options , nodes )
237
242
const modules = getModules ( css )
238
- const js = processScript ( nodes . script [ 0 ] , id , code , options , nodes , modules )
243
+ const js = await processScript ( nodes . script [ 0 ] , id , code , options , nodes , modules )
239
244
240
245
const isProduction = process . env . NODE_ENV === 'production'
241
246
const isWithStripped = options . stripWith !== false
0 commit comments