Commit cfb06e5c by 杨北旺

修改配置

1 parent 4f6eb677
module.exports = { module.exports = {
presets: ["@vue/cli-plugin-babel/preset"], presets: ["@vue/cli-plugin-babel/preset"]
plugins: [ };
[
"component",
{
libraryName: "element-ui",
styleLibraryName: "theme-chalk"
}
]
]
};
\ No newline at end of file \ No newline at end of file
...@@ -6,7 +6,16 @@ ...@@ -6,7 +6,16 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title>微前端子应用:博客</title> <!-- 使用CDN的CSS文件 -->
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.css) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="preload" as="style" />
<link href="<%= htmlWebpackPlugin.options.cdn.css[i] %>" rel="stylesheet" />
<% } %>
<!-- 使用CDN的JS文件 预加载 -->
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %>
<link href="<%= htmlWebpackPlugin.options.cdn.js[i] %>" rel="preload" as="script" />
<% } %>
<title>微前端子应用:博客</title>
</head> </head>
<body> <body>
...@@ -16,6 +25,9 @@ ...@@ -16,6 +25,9 @@
</noscript> </noscript>
<div id="app"></div> <div id="app"></div>
<!-- built files will be auto injected --> <!-- built files will be auto injected -->
<% for (var i in htmlWebpackPlugin.options.cdn && htmlWebpackPlugin.options.cdn.js) { %>
<script src="<%= htmlWebpackPlugin.options.cdn.js[i] %>"></script>
<% } %>
</body> </body>
</html> </html>
\ No newline at end of file \ No newline at end of file
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
// 根据环境引入不同配置 process.env.VUE_APP_ENV // 根据环境引入不同配置 process.env.VUE_APP_ENV
// let request = require('@/http/request.js') // let request = require('@/http/request.js')
let cfg = require('./conf.js') let cfg = require('./conf.js')
import { Http } from 'glsx-common'
let timeout = 30000 //超时时间 let timeout = 30000 //超时时间
export const fetchConfig = function(isEnv = true) { export const fetchConfig = function(isEnv = true) {
if (isEnv) { if (isEnv) {
...@@ -16,11 +17,10 @@ export const fetchConfig = function(isEnv = true) { ...@@ -16,11 +17,10 @@ export const fetchConfig = function(isEnv = true) {
Object.assign(request, { timeout }) Object.assign(request, { timeout })
return Promise.resolve(cfg) return Promise.resolve(cfg)
} }
//return window.fetch('https://', {}).then(res => res.json()) return new Http().get('https://oss-config.test.glsx.com.cn/mock/616d443d1072f92988f05a04/setting/config')
// request({ url: 'https://oss-config.test.glsx.com.cn/mock/5be17454f31545347559d499/config/oss_commodity_center', method: 'get' })
} }
export const config = { export const config = {
install(vue, cfg) { install(vue, cfg) {
vue.prototype.$config = cfg vue.prototype.$config = cfg
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -13,7 +13,7 @@ Vue.use(GLTable) ...@@ -13,7 +13,7 @@ Vue.use(GLTable)
Vue.use(ElementUI) Vue.use(ElementUI)
Vue.use(GLExternal) Vue.use(GLExternal)
export async function bootstrap({ name, id, history, common, messenger, globalState }) { export async function bootstrap({ name, id, history, common, messenger, globalState }) {
const { response, request, sign, secret } = await fetchConfig() const { response, request, sign, secret } = await fetchConfig(false)
Vue.prototype.$history = history Vue.prototype.$history = history
Vue.prototype.$messenger = messenger Vue.prototype.$messenger = messenger
Vue.prototype.$globalState = globalState Vue.prototype.$globalState = globalState
...@@ -23,7 +23,7 @@ export async function bootstrap({ name, id, history, common, messenger, globalSt ...@@ -23,7 +23,7 @@ export async function bootstrap({ name, id, history, common, messenger, globalSt
Vue.use(GLButton, { permissions: globalState.permissions || ['1-1-1-1', '2-1-1-1', '3-1-1-1'] }) Vue.use(GLButton, { permissions: globalState.permissions || ['1-1-1-1', '2-1-1-1', '3-1-1-1'] })
const routesData = common.utils.deepClone(globalState.routers) const routesData = common.utils.deepClone(globalState.routers)
// routes = getRoutes({ name, id, routesData }) // routes = getRoutes({ name, id, routesData })
routes = getRoutes(routesData) routes = getRoutes(routesData)
subscribe({ messenger }) subscribe({ messenger })
} }
......
...@@ -16,7 +16,7 @@ import render from './render' ...@@ -16,7 +16,7 @@ import render from './render'
import { routes } from '@/router' import { routes } from '@/router'
export async function start() { export async function start() {
if (window.__POWERED_BY_QIANKUN__) return if (window.__POWERED_BY_QIANKUN__) return
const { response, request, sign, secret } = await fetchConfig() const { response, request, sign, secret } = await fetchConfig(false)
Vue.prototype.$http = new Http({ response, request, sign, secret, alert: message.error, headers: { token: '1112223333444' } }) Vue.prototype.$http = new Http({ response, request, sign, secret, alert: message.error, headers: { token: '1112223333444' } })
Vue.use(GLButton, { permissions: ['1-1-1-1', '2-1-1-1', '3-1-1-1'] }) Vue.use(GLButton, { permissions: ['1-1-1-1', '2-1-1-1', '3-1-1-1'] })
render('/', routes) render('/', routes)
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
import shopModule from './shop.vue' import shopModule from './shop.vue'
import blocModule from './bloc.vue' import blocModule from './bloc.vue'
import { merchantInfo } from '../../api/modules/baseinfoApi' import { merchantInfo } from '../../api/modules/baseinfoApi'
import { utils } from 'glsx-common'
export default { export default {
name: 'index', name: 'index',
components: { components: {
......
const path = require('path') const path = require('path')
const packageName = require('./package.json').name const packageName = require('./package.json').name
const node_env = process.env.NODE_ENV === 'production' const node_env = process.env.NODE_ENV === 'production'
// const baseUrl = process.env.VUE_APP_BASE_URL;
const publicPath = node_env ? `/child/${packageName}/` : '/' const publicPath = node_env ? `/child/${packageName}/` : '/'
// const baseUrl = '/'
const resolve = dir => path.join(__dirname, dir) const resolve = dir => path.join(__dirname, dir)
const CDN_DOMAIN = 'https://cdn.bootcdn.net/'
const cdn = {
css: [
`${CDN_DOMAIN}ajax/libs/element-ui/2.11.1/theme-chalk/index.css`
],
js: [
`${CDN_DOMAIN}ajax/libs/vue/2.6.11/vue.min.js`,
`${CDN_DOMAIN}ajax/libs/vue-router/3.2.0/vue-router.min.js`,
`${CDN_DOMAIN}ajax/libs/element-ui/2.11.1/index.js`,
`${CDN_DOMAIN}ajax/libs/vuex/3.6.2/vuex.min.js`,
`${CDN_DOMAIN}ajax/libs/echarts/5.1.2/echarts.min.js`
]
}
module.exports = { module.exports = {
outputDir: `dist`, outputDir: `../dist/${packageName}`,
publicPath: publicPath, publicPath,
assetsDir: 'static', assetsDir: 'static',
productionSourceMap: false,
configureWebpack: { configureWebpack: {
resolve: { resolve: {
alias: { alias: {
...@@ -22,6 +34,14 @@ module.exports = { ...@@ -22,6 +34,14 @@ module.exports = {
library: `${packageName}-[name]`, library: `${packageName}-[name]`,
libraryTarget: 'umd', // 把微应用打包成 umd 库格式 libraryTarget: 'umd', // 把微应用打包成 umd 库格式
jsonpFunction: `webpackJsonp_${packageName}` jsonpFunction: `webpackJsonp_${packageName}`
},
externals: {
'vue': 'Vue',
'element-ui': 'ELEMENT',
'vue-router': 'VueRouter',
'vuex': 'Vuex',
'axios': 'axios',
'echarts': 'echarts'
} }
}, },
devServer: { devServer: {
...@@ -34,6 +54,12 @@ module.exports = { ...@@ -34,6 +54,12 @@ module.exports = {
} }
}, },
chainWebpack: config => { chainWebpack: config => {
config.plugin('html')
.tap(args => {
// args[0].minify.removeComments = false;
args[0].cdn = cdn
return args
})
config.plugins.delete('preload') // TODO: need test config.plugins.delete('preload') // TODO: need test
config.plugins.delete('prefetch') // TODO: need test config.plugins.delete('prefetch') // TODO: need test
config.module config.module
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!