调整 xml-loader
This commit is contained in:
parent
177df12b34
commit
15230cdd2f
|
|
@ -133,11 +133,10 @@ function getAppJson(context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = async function (content) {
|
module.exports = async function (content) {
|
||||||
// loader的缓存功能
|
|
||||||
// this.cacheable && this.cacheable();
|
|
||||||
|
|
||||||
const options = this.getOptions() || {}; //获取配置参数
|
const options = this.getOptions() || {}; //获取配置参数
|
||||||
const { context: projectContext } = options; // context 本项目路径
|
const { context: projectContext, cacheDirectory = true } = options; // context 本项目路径
|
||||||
|
// loader的缓存功能
|
||||||
|
this.cacheable && this.cacheable(cacheDirectory);
|
||||||
const callback = this.async();
|
const callback = this.async();
|
||||||
const {
|
const {
|
||||||
options: webpackLegacyOptions,
|
options: webpackLegacyOptions,
|
||||||
|
|
@ -186,7 +185,6 @@ module.exports = async function (content) {
|
||||||
`<wxs src='${wxsRelativePath}' module='${I18nModuleName}'></wxs>` +
|
`<wxs src='${wxsRelativePath}' module='${I18nModuleName}'></wxs>` +
|
||||||
source;
|
source;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// 注入全局message组件
|
// 注入全局message组件
|
||||||
if (/pages/.test(context)) {
|
if (/pages/.test(context)) {
|
||||||
|
|
@ -196,9 +194,7 @@ module.exports = async function (content) {
|
||||||
appJson.usingComponents &&
|
appJson.usingComponents &&
|
||||||
appJson.usingComponents[oakMessage]
|
appJson.usingComponents[oakMessage]
|
||||||
) {
|
) {
|
||||||
source =
|
source = source + `\n <${oakMessage}></${oakMessage}>`;
|
||||||
source +
|
|
||||||
`\n <${oakMessage}></${oakMessage}>`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -254,8 +250,7 @@ module.exports = async function (content) {
|
||||||
} else {
|
} else {
|
||||||
node.setAttribute('focus', `{{!!oakFocused.${oakValue}}}`);
|
node.setAttribute('focus', `{{!!oakFocused.${oakValue}}}`);
|
||||||
}
|
}
|
||||||
}
|
} else if (node.hasAttribute('oak:path')) {
|
||||||
else if (node.hasAttribute('oak:path')) {
|
|
||||||
// oak:path声明的属性加上oakPath和oakParent
|
// oak:path声明的属性加上oakPath和oakParent
|
||||||
const oakValue = node.getAttribute('oak:path');
|
const oakValue = node.getAttribute('oak:path');
|
||||||
node.removeAttribute('oak:path');
|
node.removeAttribute('oak:path');
|
||||||
|
|
@ -279,21 +274,29 @@ module.exports = async function (content) {
|
||||||
let newVal = '';
|
let newVal = '';
|
||||||
valArr.forEach((ele, index) => {
|
valArr.forEach((ele, index) => {
|
||||||
if (existsT(ele)) {
|
if (existsT(ele)) {
|
||||||
const head = ele.substring(0, ele.indexOf("i18n.t(") + 7);
|
const head = ele.substring(
|
||||||
|
0,
|
||||||
|
ele.indexOf('i18n.t(') + 7
|
||||||
|
);
|
||||||
let argsStr = ele.substring(ele.indexOf('i18n.t(') + 7);
|
let argsStr = ele.substring(ele.indexOf('i18n.t(') + 7);
|
||||||
argsStr = argsStr.substring(0, argsStr.indexOf(')'));
|
argsStr = argsStr.substring(0, argsStr.indexOf(')'));
|
||||||
const end = ele.substring(ele.indexOf(')'));
|
const end = ele.substring(ele.indexOf(')'));
|
||||||
const arguments = argsStr.split(',').filter(ele2 => !!ele2);
|
const arguments = argsStr
|
||||||
|
.split(',')
|
||||||
|
.filter((ele2) => !!ele2);
|
||||||
arguments &&
|
arguments &&
|
||||||
arguments.forEach((nodeVal, index) => {
|
arguments.forEach((nodeVal, index) => {
|
||||||
if (index === 0 && nodeVal.indexOf(':') === -1) {
|
if (
|
||||||
arguments.splice(
|
index === 0 &&
|
||||||
index,
|
nodeVal.indexOf(':') === -1
|
||||||
1,
|
) {
|
||||||
`'${ns}:' + ` + nodeVal
|
arguments.splice(
|
||||||
);
|
index,
|
||||||
}
|
1,
|
||||||
});
|
`'${ns}:' + ` + nodeVal
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
newVal +=
|
newVal +=
|
||||||
head +
|
head +
|
||||||
arguments.join(',') +
|
arguments.join(',') +
|
||||||
|
|
|
||||||
|
|
@ -279,6 +279,8 @@ module.exports = function (webpackEnv) {
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
plugins: [oakI18nPlugin],
|
plugins: [oakI18nPlugin],
|
||||||
|
//开启缓存
|
||||||
|
// cacheDirectory: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -292,6 +294,9 @@ module.exports = function (webpackEnv) {
|
||||||
loader: 'babel-loader',
|
loader: 'babel-loader',
|
||||||
options: {
|
options: {
|
||||||
plugins: [oakI18nPlugin],
|
plugins: [oakI18nPlugin],
|
||||||
|
//开启缓存
|
||||||
|
// cacheDirectory: false,
|
||||||
|
// presets: ['@babel/preset-env'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -326,6 +331,7 @@ module.exports = function (webpackEnv) {
|
||||||
loader: 'wxml-loader',
|
loader: 'wxml-loader',
|
||||||
options: {
|
options: {
|
||||||
context: paths.appSrc,
|
context: paths.appSrc,
|
||||||
|
cacheDirectory: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
@ -341,6 +347,7 @@ module.exports = function (webpackEnv) {
|
||||||
loader: 'wxml-loader',
|
loader: 'wxml-loader',
|
||||||
options: {
|
options: {
|
||||||
context: paths.appSrc,
|
context: paths.appSrc,
|
||||||
|
cacheDirectory: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
@ -355,6 +362,7 @@ module.exports = function (webpackEnv) {
|
||||||
loader: 'wxml-loader',
|
loader: 'wxml-loader',
|
||||||
options: {
|
options: {
|
||||||
context: paths.appSrc,
|
context: paths.appSrc,
|
||||||
|
cacheDirectory: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue