How to use the @dcloudio/uni-cli-shared.normalizePath 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 / plugin / index.js View on Github external
compiler.hooks.invalid.tap('webpack-uni-mp-invalid', (fileName, changeTime) => {
      if (
        fileName &&
        typeof fileName === 'string'
      ) { // 重新解析 entry
        const basename = path.basename(fileName)
        const deps = process.UNI_PAGES_DEPS || new Set()
        if (
          basename === 'pages.json' ||
          basename === pagesJsonJsFileName ||
          deps.has(normalizePath(fileName))
        ) {
          try {
            parseEntry()
          } catch (e) {
            console.error(e)
          }
        }
      }
    })
  }
github dcloudio / uni-app / packages / webpack-uni-mp-loader / lib / plugin / index-new.js View on Github external
Object.keys(process.UNI_SUBPACKAGES).forEach(root => {
    const subPackageVendorPath = normalizePath(path.join(root, 'common/vendor.js'))
    if (assetsKeys.indexOf(subPackageVendorPath) !== -1) {
      // TODO 理论上仅需在分包第一个 js 中添加 require common vendor,但目前不同平台可能顺序不一致,
      // 故 每个分包里的 js 里均添加一次 require
      assetsKeys.forEach(name => {
        if (
          path.extname(name) === '.js' &&
          name.indexOf(root) === 0 &&
          name !== subPackageVendorPath
        ) {
          const source = `require('${normalizePath(path.relative(path.dirname(name), subPackageVendorPath))}');` +
            compilation.assets[name].source()

          compilation.assets[name] = {
            size () {
              return Buffer.byteLength(source, 'utf8')
            },
github dcloudio / uni-app / packages / vue-cli-plugin-uni / lib / split-chunks.js View on Github external
function baseTest (module) {
    if (module.type === 'css/mini-extract') {
      return false
    }
    if (module.resource) {
      const resource = normalizePath(module.resource)
      if (
        resource.indexOf('.vue') !== -1 ||
        resource.indexOf('.nvue') !== -1 ||
        resource.indexOf(mainPath) === 0 // main.js
      ) {
        return false
      }
    }
    return true
  }
  // TODO 独立分包
github dcloudio / uni-app / packages / vue-cli-plugin-uni / packages / webpack-uni-app-loader / using-components.js View on Github external
module.exports = function(content, map) {
  this.cacheable && this.cacheable()
  const resourcePath = removeExt(
    normalizePath(path.relative(process.env.UNI_INPUT_DIR, this.resourcePath))
  )
  content = content + getUsingComponentsCode(resourcePath)
  // TODO 自动导入 vue 组件(h5,小程序,app[vue,nvue])
  // 1. 需要 template-loader 解析出所有自定义组件()
  // 2. 根据自定义组件信息生成引用代码
  // 3. node-modules中的组件不提供自动导入
  return content
}
github dcloudio / uni-app / packages / webpack-uni-mp-loader / lib / plugin / generate-component.js View on Github external
const path = require('path')
const {
  removeExt,
  normalizePath
} = require('@dcloudio/uni-cli-shared')
const {
  getComponentSet
} = require('@dcloudio/uni-cli-shared/lib/cache')

const {
  restoreNodeModules
} = require('../shared')

const uniPath = normalizePath(require.resolve('@dcloudio/uni-' + process.env.UNI_PLATFORM))

function findModule (modules, resource, altResource) {
  return modules.find(
    module => {
      let moduleResource = module.resource
      if (
        !moduleResource ||
        (
          moduleResource.indexOf('.vue') === -1 &&
          moduleResource.indexOf('.nvue') === -1
        )
      ) {
        return
      }
      moduleResource = removeExt(module.resource)
      return moduleResource === resource || moduleResource === altResource
github dcloudio / uni-app / packages / webpack-uni-pages-loader / lib / index-new.js View on Github external
}, function (root, page) {
    updatePageJson(normalizePath(path.join(root, page.path)), renameUsingComponents(
      parseStyle(page.style, root)
    ))
  })
github dcloudio / uni-app / packages / webpack-uni-pages-loader / lib / index.js View on Github external
addDependency: (file) => {
      (process.UNI_PAGES_DEPS || (process.UNI_PAGES_DEPS = new Set())).add(normalizePath(file))
      this.addDependency(file)
    }
  })
github dcloudio / uni-app / packages / webpack-uni-pages-loader / lib / index.js View on Github external
}, function (root, page) {
    checkPageEmitFile(normalizePath(path.join(root, page.path)), page.style)
  })
github dcloudio / uni-app / packages / vue-cli-plugin-hbuilderx / packages / webpack-uni-nvue-loader / lib / main.js View on Github external
function genStyleRequest(style, i, stringifyRequest) {
  const src = style.src || normalizePath(appVuePath)
  const attrsQuery = attrsToQuery(style.attrs, 'css')
  const query = `?vue&type=style&index=${i}${attrsQuery}`
  return stringifyRequest(src + query)
}