diff --git a/packages/core/src/index.js b/packages/core/src/index.js index e4e2677cc7..1ee8bcef3b 100644 --- a/packages/core/src/index.js +++ b/packages/core/src/index.js @@ -138,6 +138,7 @@ Mpx.config = { ignoreProxyWhiteList: ['id', 'dataset', 'data'], observeClassInstance: false, errorHandler: null, + warnHandler: null, proxyEventHandler: null, setDataHandler: null, forceFlushSync: false, diff --git a/packages/utils/src/log.js b/packages/utils/src/log.js index f0e174a86d..eba7143ff3 100644 --- a/packages/utils/src/log.js +++ b/packages/utils/src/log.js @@ -14,7 +14,13 @@ export function warn (msg, location, e) { } else if (condition instanceof RegExp) { ignore = condition.test(msg) } - if (!ignore) return log('warn', msg, location, e) + if (!ignore) { + const warnHandler = global.__mpx?.config.warnHandler + if (isFunction(warnHandler)) { + warnHandler(msg, location, e) + } + return log('warn', msg, location, e) + } } export function error (msg, location, e) { diff --git a/packages/webpack-plugin/lib/index.js b/packages/webpack-plugin/lib/index.js index 2c09e14c13..0ff066af65 100644 --- a/packages/webpack-plugin/lib/index.js +++ b/packages/webpack-plugin/lib/index.js @@ -1812,7 +1812,6 @@ try { } if (isWeb(mpx.mode)) { - const mpxStyleOptions = queryObj.mpxStyleOptions const firstLoader = loaders[0] ? toPosix(loaders[0].loader) : '' const isPitcherRequest = firstLoader.includes('node_modules/vue-loader/lib/loaders/pitcher') let cssLoaderIndex = -1 @@ -1837,8 +1836,7 @@ try { } if (loaderIndex > -1) { loaders.splice(loaderIndex + 1, 0, { - loader: styleCompilerPath, - options: (mpxStyleOptions && JSON.parse(mpxStyleOptions)) || {} + loader: styleCompilerPath }) } } diff --git a/packages/webpack-plugin/lib/web/processStyles.js b/packages/webpack-plugin/lib/web/processStyles.js index 5b26793e28..99fd631883 100644 --- a/packages/webpack-plugin/lib/web/processStyles.js +++ b/packages/webpack-plugin/lib/web/processStyles.js @@ -8,11 +8,8 @@ module.exports = function (styles, options, callback) { attrs (style) { const attrs = Object.assign({}, style.attrs) if (options.autoScope) attrs.scoped = true - attrs.mpxStyleOptions = JSON.stringify({ - // scoped: !!options.autoScope, - // query中包含module字符串会被新版vue-cli中的默认rules当做css-module处理 - mid: options.moduleId - }) + // query中包含module字符串会被新版vue-cli中的默认rules当做css-module处理 + attrs.mid = options.moduleId return attrs } })