提交 67fdc5ef 编写于 作者: J JiM-W

feat: 支持weex多bundle自定义bundle名称

上级 7a7a217e
...@@ -21,20 +21,24 @@ cml.config.merge({ ...@@ -21,20 +21,24 @@ cml.config.merge({
web: { web: {
dev: { dev: {
analysis: false, analysis: false,
console: false console: false,
isWrapComponent: false // 取消默认对组件的包裹
}, },
build: { build: {
analysis: false, analysis: false,
publicPath: `${publicPath}/web/`, publicPath: `${publicPath}/web/`,
apiPrefix apiPrefix,
isWrapComponent: false // 取消默认对组件的包裹
} }
}, },
weex: { weex: {
dev: { dev: {
isWrapComponent: false // 取消默认对组件的包裹
}, },
build: { build: {
publicPath: `${publicPath}/weex/`, publicPath: `${publicPath}/weex/`,
apiPrefix apiPrefix,
isWrapComponent: false // 取消默认对组件的包裹
}, },
custom: { custom: {
publicPath: `${publicPath}/wx/`, publicPath: `${publicPath}/wx/`,
......
...@@ -125,10 +125,17 @@ module.exports = function({webpackConfig, options, compiler}) { ...@@ -125,10 +125,17 @@ module.exports = function({webpackConfig, options, compiler}) {
if (mpa && mpa.weexMpa && Array.isArray(mpa.weexMpa)) { // 配置了weex多页面 if (mpa && mpa.weexMpa && Array.isArray(mpa.weexMpa)) { // 配置了weex多页面
let weexMpa = mpa.weexMpa; let weexMpa = mpa.weexMpa;
for (let i = 0; i < weexMpa.length ; i++) { for (let i = 0; i < weexMpa.length ; i++) {
weexBundles.push({ if (typeof weexMpa[i].name === 'string') {
bundle: `weex/${entry}${i}.js`, weexBundles.push({
paths: weexMpa[i].paths bundle: `weex/${weexMpa[i].name}.js`,
}) paths: weexMpa[i].paths
})
} else {
weexBundles.push({
bundle: `weex/${entry}${i}.js`,
paths: weexMpa[i].paths
})
}
} }
} else { // 兼容原来的没有配置的情况 } else { // 兼容原来的没有配置的情况
let allPaths = routerConfig.routes.reduce((result, current) => { let allPaths = routerConfig.routes.reduce((result, current) => {
......
...@@ -13,6 +13,7 @@ const ChameleonErrorsWebpackPlugin = require('chameleon-errors-webpack-plugin'); ...@@ -13,6 +13,7 @@ const ChameleonErrorsWebpackPlugin = require('chameleon-errors-webpack-plugin');
const fs = require('fs'); const fs = require('fs');
const cmlUtils = require('chameleon-tool-utils'); const cmlUtils = require('chameleon-tool-utils');
const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin'); const ExtraWatchWebpackPlugin = require('extra-watch-webpack-plugin');
const DuplicatePackageCheckerPlugin = require('duplicate-package-checker-webpack-plugin');
module.exports = function (options) { module.exports = function (options) {
let { let {
...@@ -190,6 +191,7 @@ module.exports = function (options) { ...@@ -190,6 +191,7 @@ module.exports = function (options) {
if (options.media === 'dev') { if (options.media === 'dev') {
// dev模式添加domainKey参数 // dev模式添加domainKey参数
Object.keys(domain).forEach(key => { Object.keys(domain).forEach(key => {
if (domain[key].toLowerCase() === 'localhost') { if (domain[key].toLowerCase() === 'localhost') {
...@@ -201,7 +203,12 @@ module.exports = function (options) { ...@@ -201,7 +203,12 @@ module.exports = function (options) {
new ExtraWatchWebpackPlugin({ new ExtraWatchWebpackPlugin({
dirs: [path.join(cml.projectRoot, 'mock/api')] dirs: [path.join(cml.projectRoot, 'mock/api')]
}) })
) );
commonConfig.plugins.push(
new DuplicatePackageCheckerPlugin({
verbose: true,
}),
);
} }
// 兼容旧版api // 兼容旧版api
commonConfig.plugins.push(new webpack.DefinePlugin({ commonConfig.plugins.push(new webpack.DefinePlugin({
......
...@@ -484,8 +484,12 @@ exports.getWeexEntry = function (options) { ...@@ -484,8 +484,12 @@ exports.getWeexEntry = function (options) {
if (mpa && mpa.weexMpa && Array.isArray(mpa.weexMpa)) { // 配置了weex多页面 if (mpa && mpa.weexMpa && Array.isArray(mpa.weexMpa)) { // 配置了weex多页面
let weexMpa = mpa.weexMpa; let weexMpa = mpa.weexMpa;
for (let i = 0; i < weexMpa.length ; i++) { for (let i = 0; i < weexMpa.length ; i++) {
let newEntry = entryFile.map((item) => (item === entryJS) ? `${item}?query=${i}` : item) let newEntry = entryFile.map((item) => (item === entryJS) ? `${item}?query=${i}` : item);
entry[`${entryName}${i}`] = newEntry if (typeof weexMpa[i].name === 'string') {
entry[`${weexMpa[i].name}`] = newEntry;
} else {
entry[`${entryName}${i}`] = newEntry;
}
} }
} else { // 兼容原来的没有配置的情况 } else { // 兼容原来的没有配置的情况
entry[`${entryName}`] = entryFile entry[`${entryName}`] = entryFile
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
"copy-webpack-plugin": "4.5.2", "copy-webpack-plugin": "4.5.2",
"css-hot-loader": "1.3.9", "css-hot-loader": "1.3.9",
"css-loader": "0.28.11", "css-loader": "0.28.11",
"duplicate-package-checker-webpack-plugin": "^2.1.0",
"envinfo": "^7.5.1", "envinfo": "^7.5.1",
"eventsource-polyfill": "0.9.6", "eventsource-polyfill": "0.9.6",
"express": "4.16.3", "express": "4.16.3",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册