项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Deze repo is gearchiveerd. U kunt bestanden bekijken en het klonen, maar niet pushen of problemen/pull-requests openen.
 
 
 
 

23 regels
917 B

  1. // this is a utility loader that takes a *.vue file, parses it and returns
  2. // the requested language block, e.g. the content inside <template>, for
  3. // further processing.
  4. const path = require('path')
  5. const parse = require('./parser')
  6. const loaderUtils = require('loader-utils')
  7. module.exports = function (content) {
  8. this.cacheable()
  9. const query = loaderUtils.getOptions(this) || {}
  10. const context = (this._compiler && this._compiler.context) || this.options.context || process.cwd()
  11. let filename = path.basename(this.resourcePath)
  12. filename = filename.substring(0, filename.lastIndexOf(path.extname(filename))) + '.vue'
  13. const sourceRoot = path.dirname(path.relative(context, this.resourcePath))
  14. const parts = parse(content, filename, this.sourceMap, sourceRoot)
  15. let part = parts[query.type]
  16. if (Array.isArray(part)) {
  17. part = part[query.index]
  18. }
  19. this.callback(null, part.content, part.map)
  20. }