Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!content.trim()) {
content = ''
}
cacheTemplate(realResourcePath, content)
const query = qs.parse(this.resourceQuery.slice(1))
const {
id
} = query
const compilerOptions = {
scopeId: query.scoped ? `data-v-${id}` : null,
target: getPlatformTarget(),
md5: md5(content.trim() + process.env.UNI_PLATFORM),
realResourcePath
}
cacheCompilerOptions(realResourcePath, compilerOptions)
// 向 vue-loader templateLoader 传递 compilerOptions
const vueLoaderOptions = this.loaders[0]
if (vueLoaderOptions.ident === 'vue-loader-options') {
Object.assign(vueLoaderOptions.options.compilerOptions, compilerOptions)
} else {
throw new Error('vue-loader-options parse error')
}
}
return content
}
function emitFile (filePath, source, compilation) {
const emitFileMD5 = md5(filePath + source)
if (emitFileCaches[filePath] !== emitFileMD5) {
emitFileCaches[filePath] = emitFileMD5
compilation.assets[filePath] = {
size () {
return Buffer.byteLength(source, 'utf8')
},
source () {
return source
}
}
}
}
function emitFile (filePath, source, compilation) {
const emitFileMD5 = md5(filePath + source)
if (emitFileCaches[filePath] !== emitFileMD5) {
emitFileCaches[filePath] = emitFileMD5
compilation.assets[filePath] = {
size () {
return Buffer.byteLength(source, 'utf8')
},
source () {
return source
}
}
}
}