xwt
2 天以前 0d3eadb50310ca60b8871e967e64da01aa25a9ad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const path = require('path')
 
const isWin = /^win/.test(process.platform)
 
const normalizePath = path => (isWin ? path.replace(/\\/g, '/') : path)
 
module.exports = function (content, map) {
  this.cacheable && this.cacheable()
  const resourcePath = normalizePath(this.resourcePath)
  if (
    resourcePath !== normalizePath(path.resolve(process.env.UNI_INPUT_DIR, 'App.vue')) &&
    content.indexOf('platform="mp-weixin"') === -1 // 小程序组件暂不加scoped
  ) {
    return this.callback(null, content.replace(/(<style\b[^><]*)>/ig, '$1 scoped>'), map)
  }
  this.callback(null, content, map)
}