Blame view

node_modules/mpvue-loader/lib/selector.js 851 Bytes
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  // this is a utility loader that takes a *.vue file, parses it and returns
  // the requested language block, e.g. the content inside <template>, for
  // further processing.
  
  var path = require('path')
  var parse = require('./parser')
  var loaderUtils = require('loader-utils')
  var { defaultStylePart } = require('./mp-compiler/util')
  
  module.exports = function (content) {
    this.cacheable()
    var query = loaderUtils.getOptions(this) || {}
    var context = (this._compiler && this._compiler.context) || this.options.context || process.cwd()
    var filename = path.relative(context, this.resourcePath).replace(/\..+$/, '.vue')
    var parts = parse(content, filename, this.sourceMap)
    var part = parts[query.type]
    if (Array.isArray(part)) {
      part = part[query.index]
    }
    part = part || defaultStylePart
    this.callback(null, part.content, part.map)
  }