代码拉取完成,页面将自动刷新
同步操作将从 NeatLogic/neatlogic-web 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
const path = require('path');
const glob = require('glob');
let src = './src';
let baseImg = './public/resource';
let importModuleUrl = process.env.VUE_APP_IMPORT_MODULE_URL || './src/dummy-module';
let baseConfiglUrl = './src/dummy-module'; // 如果不引用的话,就引用本地的空文件夹
let localUrl = '../neatlogic-web/src/resources';
let pageTitle = 'neatlogic'; //页面标题名称
const { tenantName, urlPrefix } = require('./apiconfig.json');
process.env.VUE_APP_TENANT = tenantName; // 租户名称
process.env.VUE_APP_LOGINTITLE = 'welcome';
function getPages(pageList) {
const pages = {};
if (!pageList) {
const pagePath = glob.sync(src + '/views/pages/*/router.js');
let pagePathList = [...pagePath];
let importModuleList = [];
let customPagePath = [];
let importModulePathList;
importModulePathList = glob.sync(`${importModuleUrl}/**/router.js`);
if (importModulePathList && importModulePathList.length > 0) {
customPagePath.push(...importModulePathList);
}
pagePathList.push(...customPagePath);
pagePathList.forEach(p => {
let filename = '';
let customImportModuleName = ''; // 自定义导入模块名称
const projectFilename = p.match(/src\/views\/pages\/(.*)\/router\.js/);
const importFilename = p.match(/\/[^\/]+\/router\.js$/);
if (projectFilename) {
filename = projectFilename[1];
} else if (importFilename) {
customImportModuleName = importFilename[0].match(/\/([^\/]+)\/router\.js$/);
if (customImportModuleName) {
filename = customImportModuleName[1];
importModuleList.push(filename);
}
}
const newpage = {};
let pageLogin = `${pageTitle}-${filename}`;
if (`${filename}` == 'login') {
pageLogin = `${pageTitle}`;
}
newpage[filename] = {
entry: importModuleList.includes(filename) ? `${importModuleUrl}/${filename}/${filename}.js` : `${src}/views/pages/${filename}/${filename}.js`,
template: `public/index.html`,
filename: `${filename}.html`,
title: pageLogin, // 标题名称+参数
chunks: [`chunk-vendors`, `chunk-common`, `${filename}`]
};
Object.assign(pages, newpage);
});
} else {
//eg:['process','dashboard']
let list = typeof pageList == 'string' ? JSON.parse(pageList) : pageList;
list.forEach(p => {
const newpage = {};
newpage[p] = {
entry: importModuleList.includes(p) ? `${importModuleUrl}/${p}/${p}.js` : `${src}/views/pages/${p}/${p}.js`,
template: `public/index.html`,
filename: `${p}.html`,
title: `${pageTitle}-${p}`, // 标题名称+参数
chunks: [`chunk-vendors`, `chunk-common`, `${p}`]
};
Object.assign(pages, newpage);
});
}
return pages;
}
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
css: {
loaderOptions: {
less: {
lessOptions: {
javascriptEnabled: true,
globalVars: {
'top-height': '50px',
'actionbar-height': '50px',
'space-normal': '16px',
'space-md': '12px',
'space-sm': '10px',
'space-icon': '3px'
}
}
}
}
},
publicPath: process.env.NODE_ENV === 'development' ? '/' + tenantName + '/' : '/', // 修复打包不需要带租户的问题
assetsDir: 'resource',
productionSourceMap: false,
runtimeCompiler: true,
pages: getPages(process.env.VUE_APP_PAGE_LIST),
configureWebpack: {
performance: {
hints: false
}
},
chainWebpack: config => {
config.module.rule('vue').use('vue-path-injector').loader(require.resolve('./vue-path-injector.js')).after('vue-loader').end();
config.resolve.alias.set('@', resolve(src));
config.resolve.alias.set('dummy-module', resolve(baseConfiglUrl));
config.resolve.alias.set('base-module', resolve(localUrl));
config.resolve.alias.set('img-module', resolve(baseImg));
config.resolve.alias.set('import-module-url', path.resolve(__dirname, importModuleUrl)); // path.resolve 解析相对路径为绝对路径,解决require.context 获取router.js/config.js 文件,路径找不到问题
config.resolve.alias.set('assets', resolve(src + '/resources/assets'));
config.resolve.alias.set('publics', resolve('./public/resource'));
config.resolve.alias.set('components', resolve(src + '/resources/components'));
config.resolve.alias.set('pages', resolve(src + '/views/pages'));
config.resolve.alias.set('api', resolve(src + '/resources/api'));
config.resolve.alias.set('css-module', resolve(src + '/resources/assets/css'));
// config.plugins.delete('prefetch');
// config.plugins.delete('preload');
// if (process.env.NODE_ENV === 'production') {
// config.optimization.minimize(true);
// config.optimization.splitChunks({
// chunks:'all',
// cacheGroups: {
// libs: {
// name: 'chunk-libs',
// test: /[\\/]node_modules[\\/]/,
// priority: 10,
// chunks: 'initial'
// },
// antv:{
// name: 'chunk-antv',
// priority: 20,
// test: /[\\/]node_modules[\\/]_?@antv(.*)/
// },
// tsUI: {
// name: 'chunk-tsUI',
// priority: 21,
// test: /[\\/]node_modules[\\/]_?neatlogic-ui(.*)/
// },
// lodash: {
// name: 'chunk-lodash',
// priority: 22,
// test: /[\\/]node_modules[\\/]_?lodash(.*)/
// }
// }
// });
// }
},
devServer: {
open: true,
port: '8081',
https: false,
hot: true,
client: {
overlay: false
},
//disableHostCheck: true,
proxy: {
'/([^/]+)/anonymous/api/': {
target: urlPrefix,
changeOrigin: true,
secure: false,
pathRewrite: {
'^/([^/]+)/anonymous/api/(.*)': '/neatlogic/anonymous/api/$2'
}
},
'/([^/]+)/public/api/': {
target: urlPrefix,
changeOrigin: true,
secure: false,
pathRewrite: {
'^/([^/]+)/public/api/(.*)': '/neatlogic/public/api/$2'
},
headers: {
Tenant: tenantName
}
},
'/([^/]+)/api/': {
target: urlPrefix,
changeOrigin: true,
secure: false,
pathRewrite: {
'^/([^/]+)/api/(.*)': '/neatlogic/api/$2'
},
headers: {
Tenant: tenantName
}
},
'/([^/]+)/([^/]+)/check': {
target: urlPrefix,
changeOrigin: true,
secure: false,
pathRewrite: {
'^/([^/]+)/([^/]+)/check$': '/neatlogic/$2/check/$1'
},
headers: {
Tenant: tenantName
}
}
}
// ,
// progress:false
},
// 将less挂到全局
pluginOptions: {
'style-resources-loader': {
preProcessor: 'less',
patterns: []
// patterns: [path.resolve(__dirname, "./src/resources/assets/css/variable.less")]
}
}
};
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。