提交 f6461c06 编写于 作者: Q qiang

fix: 移除部分含有错误引用的 wxss 文件

上级 7459c1f1
......@@ -64,6 +64,7 @@ module.exports = function generateComponent (compilation) {
const concatenatedModules = modules.filter(module => module.modules)
const uniModuleId = modules.find(module => module.resource && normalizePath(module.resource) === uniPath).id
const wxssImports = {}
Object.keys(assets).forEach(name => {
if (components.has(name.replace('.js', ''))) {
......@@ -81,7 +82,7 @@ module.exports = function generateComponent (compilation) {
let resource = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, '..', modulePath))
const altResource = normalizePath(path.resolve(process.env.UNI_INPUT_DIR, modulePath))
if (
if (
/^win/.test(process.platform) &&
modulePath.includes('@dcloudio') &&
(
......@@ -125,6 +126,24 @@ module.exports = function generateComponent (compilation) {
assets[name].source = newSource
}
}
if (name.endsWith('.wxss')) {
// 移除部分含有错误引用的 wxss 文件
const origSource = assets[name].source().trim()
const result = origSource.match(/^@import ["'](.+?)["']$/)
if (result) {
const wxssPath = path.join(path.dirname(name), result[1])
if (Object.keys(assets).includes(wxssPath)) {
wxssImports[wxssPath] = wxssImports[wxssPath] || []
wxssImports[wxssPath].push(name)
} else {
if (wxssImports[name]) {
wxssImports[name].forEach(name => delete assets[name])
delete wxssImports[name]
}
delete assets[name]
}
}
}
})
}
if (process.env.UNI_FEATURE_OBSOLETE !== 'false') {
......@@ -158,4 +177,4 @@ function removeUnusedComponent (name) {
fs.renameSync(path.join(process.env.UNI_OUTPUT_DIR, name + '.json'), path.join(process.env.UNI_OUTPUT_DIR, name +
'.bak.json'))
} catch (e) {}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册