How to use the @dcloudio/uni-cli-shared.md5 function in @dcloudio/uni-cli-shared

To help you get started, we’ve selected a few @dcloudio/uni-cli-shared examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dcloudio / uni-app / packages / webpack-uni-mp-loader / lib / template.js View on Github external
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
}
github dcloudio / uni-app / packages / webpack-uni-mp-loader / lib / plugin / index.js View on Github external
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
      }
    }
  }
}
github dcloudio / uni-app / packages / webpack-uni-mp-loader / lib / plugin / index-new.js View on Github external
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
      }
    }
  }
}