小程序 debugPanel
This commit is contained in:
parent
7b60a3b7c4
commit
617a2c801b
|
|
@ -84,6 +84,7 @@ const isSrc = (name) => name === 'src';
|
||||||
|
|
||||||
const isDynamicSrc = (src) => /\{\{/.test(src);
|
const isDynamicSrc = (src) => /\{\{/.test(src);
|
||||||
const oakMessage = 'oak-message';
|
const oakMessage = 'oak-message';
|
||||||
|
const oakDebugPanel = 'oak-debugPanel';
|
||||||
const oakRegex = /(\/*[a-zA-Z0-9_-])*\/app\/|(\\*[a-zA-Z0-9_-])*\\app\\/;
|
const oakRegex = /(\/*[a-zA-Z0-9_-])*\/app\/|(\\*[a-zA-Z0-9_-])*\\app\\/;
|
||||||
const localRegex = /(\/*[a-zA-Z0-9_-])*\/src+\/|(\\*[a-zA-Z0-9_-])*\\src+\\/;
|
const localRegex = /(\/*[a-zA-Z0-9_-])*\/src+\/|(\\*[a-zA-Z0-9_-])*\\src+\\/;
|
||||||
const oakPagesOrComponentsRegex =
|
const oakPagesOrComponentsRegex =
|
||||||
|
|
@ -151,7 +152,7 @@ module.exports = async function (content) {
|
||||||
_compiler = {},
|
_compiler = {},
|
||||||
resourcePath,
|
resourcePath,
|
||||||
} = this;
|
} = this;
|
||||||
const { output } = _compiler.options;
|
const { output, mode } = _compiler.options;
|
||||||
const { path: outputPath } = output;
|
const { path: outputPath } = output;
|
||||||
const { context, target } = webpackLegacyOptions || this;
|
const { context, target } = webpackLegacyOptions || this;
|
||||||
const issuer = _compilation.moduleGraph.getIssuer(this._module);
|
const issuer = _compilation.moduleGraph.getIssuer(this._module);
|
||||||
|
|
@ -202,6 +203,14 @@ module.exports = async function (content) {
|
||||||
) {
|
) {
|
||||||
source = source + `\n <${oakMessage}></${oakMessage}>`;
|
source = source + `\n <${oakMessage}></${oakMessage}>`;
|
||||||
}
|
}
|
||||||
|
if (
|
||||||
|
mode !== 'production' &&
|
||||||
|
appJson &&
|
||||||
|
appJson.usingComponents &&
|
||||||
|
appJson.usingComponents[oakDebugPanel]
|
||||||
|
) {
|
||||||
|
source = source + `\n <${oakDebugPanel}></${oakDebugPanel}>`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const doc = new DOMParser({
|
const doc = new DOMParser({
|
||||||
|
|
|
||||||
|
|
@ -377,6 +377,10 @@ module.exports = function (webpackEnv) {
|
||||||
exclude: ['*/weui-miniprogram/*'],
|
exclude: ['*/weui-miniprogram/*'],
|
||||||
include: ['project.config.json', 'sitemap.json'],
|
include: ['project.config.json', 'sitemap.json'],
|
||||||
split: isEnvProduction,
|
split: isEnvProduction,
|
||||||
|
debugPanel: {
|
||||||
|
name: 'oak-debugPanel',
|
||||||
|
show: !isEnvProduction,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
new webpack.DefinePlugin(env.stringified),
|
new webpack.DefinePlugin(env.stringified),
|
||||||
new StylelintPlugin({
|
new StylelintPlugin({
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,6 @@ function replaceDoubleSlash(str) {
|
||||||
class OakWeChatMpPlugin {
|
class OakWeChatMpPlugin {
|
||||||
constructor(options = {}) {
|
constructor(options = {}) {
|
||||||
this.options = Object.assign(
|
this.options = Object.assign(
|
||||||
{},
|
|
||||||
{
|
{
|
||||||
context: path.resolve(process.cwd(), 'src'),
|
context: path.resolve(process.cwd(), 'src'),
|
||||||
clear: true,
|
clear: true,
|
||||||
|
|
@ -78,6 +77,10 @@ class OakWeChatMpPlugin {
|
||||||
vendorChunkName: 'vendor',
|
vendorChunkName: 'vendor',
|
||||||
runtimeChunkName: 'runtime',
|
runtimeChunkName: 'runtime',
|
||||||
split: true,
|
split: true,
|
||||||
|
debugPanel: {
|
||||||
|
name: 'oak-debugPanel',
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|
@ -329,10 +332,14 @@ class OakWeChatMpPlugin {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const c of Object.values(usingComponents)) {
|
for (const k of Object.keys(usingComponents)) {
|
||||||
|
const c = usingComponents[k];
|
||||||
if (c.indexOf('plugin://') === 0) {
|
if (c.indexOf('plugin://') === 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (k === this.options.debugPanel.name && !this.options.debugPanel.show) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (c.indexOf('/npm_components') === 0) {
|
if (c.indexOf('/npm_components') === 0) {
|
||||||
const component = c.replace(
|
const component = c.replace(
|
||||||
/\/npm_components/,
|
/\/npm_components/,
|
||||||
|
|
@ -731,6 +738,9 @@ class OakWeChatMpPlugin {
|
||||||
if (appJson.usingComponents) {
|
if (appJson.usingComponents) {
|
||||||
for (let ck of Object.keys(appJson.usingComponents)) {
|
for (let ck of Object.keys(appJson.usingComponents)) {
|
||||||
let component = appJson.usingComponents[ck];
|
let component = appJson.usingComponents[ck];
|
||||||
|
if (ck === this.options.debugPanel.name && !this.options.debugPanel.show) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (getIsOak(component)) {
|
if (getIsOak(component)) {
|
||||||
component = replaceOakPrefix(component);
|
component = replaceOakPrefix(component);
|
||||||
} else if (getIsLocal(component)) {
|
} else if (getIsLocal(component)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue