Skip to content

Commit

Permalink
fix: 去除webpack-plugin/index.js中对于loader插入的改动,完全由mpx-cli中进行相关loader注入
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackgan3 committed Dec 23, 2024
1 parent f1dcde1 commit 8658fc9
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions packages/webpack-plugin/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,11 @@ const wxssLoaderPath = normalize.lib('wxss/index')
const wxmlLoaderPath = normalize.lib('wxml/loader')
const wxsLoaderPath = normalize.lib('wxs/loader')
const styleCompilerPath = normalize.lib('style-compiler/index')
const styleStripConditaionalPath = normalize.lib('style-compiler/strip-conditional-loader')
const templateCompilerPath = normalize.lib('template-compiler/index')
const jsonCompilerPath = normalize.lib('json-compiler/index')
const jsonThemeCompilerPath = normalize.lib('json-compiler/theme')
const jsonPluginCompilerPath = normalize.lib('json-compiler/plugin')
const extractorPath = normalize.lib('extractor')
const selectorPath = normalize.lib('selector')
const async = require('async')
const { parseQuery } = require('loader-utils')
const stringifyLoadersAndResource = require('./utils/stringify-loaders-resource')
Expand Down Expand Up @@ -1777,7 +1775,7 @@ try {
})

const typeLoaderProcessInfo = {
styles: ['node_modules/css-loader', wxssLoaderPath, styleCompilerPath, styleStripConditaionalPath],
styles: ['node_modules/css-loader', wxssLoaderPath, styleCompilerPath],
template: ['node_modules/html-loader', wxmlLoaderPath, templateCompilerPath]
}

Expand Down Expand Up @@ -1835,20 +1833,6 @@ try {
loader: extractorPath
})
}
if (type === 'styles') {
// 判断最后一个loader是否是 selectorPath, 如果是,则在sectorPath之前插入strip-conditional
const lastLoader = loaders[loaders.length - 1]
if (lastLoader.loader.includes(selectorPath)) {
loaders.splice(loaders.length - 1, 0, {
loader: styleStripConditaionalPath
})
} else {
// 在最后一个插入strip-conditional
loaders.push({
loader: styleStripConditaionalPath
})
}
}
createData.resource = addQuery(createData.resource, { mpx: MPX_PROCESSED_FLAG }, true)
}
// mpxStyleOptions 为 mpx style 文件的标识,避免 Vue 文件插入 styleCompiler 后导致 vue scoped 样式隔离失效
Expand Down

0 comments on commit 8658fc9

Please sign in to comment.