Files
fitness_walk_nwnu/node_modules/@dcloudio/vue-cli-plugin-uni/packages/webpack-scoped-loader/index.js
T
2026-09-08 20:28:54 +08:00

18 lines
604 B
JavaScript

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)
}