提交 d5e4449b 编写于 作者: H huyuangang 提交者: yylgit

fixbug

wxml
上级 479d4304
...@@ -19,7 +19,7 @@ module.exports = function(loaderContext, jsonObject, cmlType) { ...@@ -19,7 +19,7 @@ module.exports = function(loaderContext, jsonObject, cmlType) {
} }
cmlUtils.addNpmComponents(jsonObject, jsonPath, cmlType, context) cmlUtils.addNpmComponents(jsonObject, jsonPath, cmlType, context)
return jsonObject; return jsonObject;
......
...@@ -678,7 +678,6 @@ _.handleComponentUrl = function (context, cmlFilePath, comPath, cmlType) { ...@@ -678,7 +678,6 @@ _.handleComponentUrl = function (context, cmlFilePath, comPath, cmlType) {
refUrl refUrl
} }
} }
if (~filePath.indexOf('node_modules')) { if (~filePath.indexOf('node_modules')) {
refUrl = _.npmComponentRefPath(filePath, context); refUrl = _.npmComponentRefPath(filePath, context);
// 改为相对路径 // 改为相对路径
...@@ -687,18 +686,18 @@ _.handleComponentUrl = function (context, cmlFilePath, comPath, cmlType) { ...@@ -687,18 +686,18 @@ _.handleComponentUrl = function (context, cmlFilePath, comPath, cmlType) {
} else { } else {
// 改成相对路径 // 改成相对路径
refUrl = _.handleRelativePath(cmlFilePath, filePath); refUrl = _.handleRelativePath(cmlFilePath, filePath);
}
refUrl = refUrl.replace(new RegExp(`(\\.cml|\\.${cmlType}\\.cml)`), ''); refUrl = refUrl.replace(new RegExp(`(\\.cml|\\.${cmlType}\\.cml)`), '');
if (cmlType === 'wx') { if (cmlType === 'wx') {
refUrl = refUrl.replace(/\.wxml/g, ''); refUrl = refUrl.replace(/\.wxml$/g, '');
} }
if (cmlType === 'alipay') { if (cmlType === 'alipay') {
refUrl = refUrl.replace(/\.axml/g, ''); refUrl = refUrl.replace(/\.axml$/g, '');
} }
if (cmlType === 'baidu') { if (cmlType === 'baidu') {
refUrl = refUrl.replace(/\.swan/g, ''); refUrl = refUrl.replace(/\.swan$/g, '');
}
} }
return { return {
......
...@@ -365,6 +365,22 @@ describe('index.js', function () { ...@@ -365,6 +365,22 @@ describe('index.js', function () {
expect(result.isCml).to.equal(true); expect(result.isCml).to.equal(true);
}) })
it('handleComponentUrl isCml true wxml', function() {
global.cml = {};
_.setCli(true);
cml.config = require('./testlib/cli/config.js');
cml.utils = require('../src/index.js');
cml.projectRoot = path.join(__dirname, 'testlib/demo-project');
cml.config.merge({
})
var cmlFilePath = path.join(__dirname, 'testlib/demo-project/src/pages/page1/page1.cml');
var comrefPath = 'vant-weapp/test'
let result = _.handleComponentUrl(cml.projectRoot, cmlFilePath, comrefPath, 'wx');
expect(result.refUrl).to.equal('./../../npm/vant-weapp/test');
})
it('findInterfaceFile', function() { it('findInterfaceFile', function() {
global.cml = {}; global.cml = {};
_.setCli(true); _.setCli(true);
......
...@@ -33,7 +33,7 @@ module.exports = function (options) { ...@@ -33,7 +33,7 @@ module.exports = function (options) {
] ]
} }
if (media === 'export') { if (media === 'export') {
return getMiniAppExportConfig(options); return getMiniAppExportConfig(merge(commonConfig, buildConfig), options);
} }
return merge(commonConfig, buildConfig) return merge(commonConfig, buildConfig)
} }
...@@ -27,7 +27,7 @@ var miniappConfig = { ...@@ -27,7 +27,7 @@ var miniappConfig = {
'process.env.NODE_ENV': JSON.stringify('production') 'process.env.NODE_ENV': JSON.stringify('production')
}, },
entry: [ entry: [
'./components' './src/components'
], ],
publicPath: '../../' publicPath: '../../'
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册