Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 08a83b8f
authored
Nov 22, 2022
by
xinla
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
打包使用cdn 配置
1 parent
bd3dbaf9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
37 deletions
linkwe-pc/env.js
linkwe-pc/src/router/index.js
linkwe-pc/vue.config.js
linkwe-pc/env.js
View file @
08a83b8
...
@@ -4,18 +4,18 @@
...
@@ -4,18 +4,18 @@
*/
*/
const
envs
=
{
const
envs
=
{
development
:
{
development
:
{
DOMAIN
:
'http://de
mo
.linkwechat.net'
,
DOMAIN
:
'http://de
v
.linkwechat.net'
,
BASE_URL
:
'./'
,
// 路由基础路径
BASE_URL
:
'./'
,
// 路由基础路径
BASE_API
:
'http://de
mo.linkwechat.net/linkwechat
-api'
,
BASE_API
:
'http://de
v.linkwechat.net/linkwechat-dev
-api'
,
SYSTEM_API
:
'/linkwechat-api'
,
// 接口基础路径/nginx接口转发路径
SYSTEM_API
:
'/linkwechat-
dev-
api'
,
// 接口基础路径/nginx接口转发路径
},
},
test
:
{
test
:
{
DOMAIN
:
'http://de
mo
.linkwechat.net'
,
DOMAIN
:
'http://de
v
.linkwechat.net'
,
BASE_URL
:
'./'
,
// 路由基础路径
BASE_URL
:
'./'
,
// 路由基础路径
BASE_API
:
'http://de
mo.linkwechat.net/linkwechat
-api'
,
BASE_API
:
'http://de
v.linkwechat.net/linkwechat-dev
-api'
,
SYSTEM_API
:
'/linkwechat-api'
,
SYSTEM_API
:
'/linkwechat-
dev-
api'
,
_ISGZIP
:
true
,
// 是否开启gzip压缩
_ISGZIP
:
true
,
// 是否开启gzip压缩
_ISCDN
:
fals
e
,
// 是否开启cdn加速
_ISCDN
:
tru
e
,
// 是否开启cdn加速
},
},
production
:
{
production
:
{
DOMAIN
:
'http://demo.linkwechat.net'
,
DOMAIN
:
'http://demo.linkwechat.net'
,
...
@@ -23,7 +23,7 @@ const envs = {
...
@@ -23,7 +23,7 @@ const envs = {
BASE_API
:
'http://demo.linkwechat.net/linkwechat-api'
,
BASE_API
:
'http://demo.linkwechat.net/linkwechat-api'
,
SYSTEM_API
:
'/linkwechat-api'
,
SYSTEM_API
:
'/linkwechat-api'
,
_ISGZIP
:
true
,
// 是否开启gzip压缩
_ISGZIP
:
true
,
// 是否开启gzip压缩
_ISCDN
:
fals
e
,
// 是否开启cdn加速
_ISCDN
:
tru
e
,
// 是否开启cdn加速
},
},
}
}
const
env
=
Object
.
assign
(
const
env
=
Object
.
assign
(
...
...
linkwe-pc/src/router/index.js
View file @
08a83b8
import
Vue
from
'vue'
import
Vue
from
'vue'
import
Router
from
'vue-router'
import
Vue
Router
from
'vue-router'
Vue
.
use
(
Router
)
Vue
.
use
(
Vue
Router
)
const
originalPush
=
Router
.
prototype
.
push
const
originalPush
=
Vue
Router
.
prototype
.
push
Router
.
prototype
.
push
=
function
push
(
location
)
{
Vue
Router
.
prototype
.
push
=
function
push
(
location
)
{
return
originalPush
.
call
(
this
,
location
).
catch
((
err
)
=>
err
)
return
originalPush
.
call
(
this
,
location
).
catch
((
err
)
=>
err
)
}
}
...
@@ -72,8 +72,7 @@ const devRoutes = [
...
@@ -72,8 +72,7 @@ const devRoutes = [
{
{
path
:
'detail'
,
path
:
'detail'
,
name
:
'group-code-analyse'
,
name
:
'group-code-analyse'
,
component
:
(
resolve
)
=>
component
:
(
resolve
)
=>
require
([
'@/views/commodityCenter/commodityManage/detail'
],
resolve
),
require
([
'@/views/commodityCenter/commodityManage/detail'
],
resolve
),
meta
:
{
meta
:
{
title
:
'商品管理'
,
title
:
'商品管理'
,
activeMenu
:
'/commodityCenter/commodityManage'
,
activeMenu
:
'/commodityCenter/commodityManage'
,
...
@@ -159,10 +158,9 @@ export const constantRoutes = [
...
@@ -159,10 +158,9 @@ export const constantRoutes = [
},
},
]
]
export
default
new
Router
({
export
default
new
Vue
Router
({
// mode: process.env.VUE_APP_ENV === 'test' ? 'hash' : 'history', // history 下 element ui 存在bug
// mode: process.env.VUE_APP_ENV === 'test' ? 'hash' : 'history', // history 下 element ui 存在bug
// base: window.lwConfig.BASE_URL,
// base: window.lwConfig.BASE_URL,
scrollBehavior
:
()
=>
({
y
:
0
}),
scrollBehavior
:
()
=>
({
y
:
0
}),
routes
:
routes
:
process
.
env
.
NODE_ENV
!==
'development'
?
constantRoutes
:
constantRoutes
.
concat
(
devRoutes
),
process
.
env
.
NODE_ENV
!==
'development'
?
constantRoutes
:
constantRoutes
.
concat
(
devRoutes
),
})
})
linkwe-pc/vue.config.js
View file @
08a83b8
'use strict'
'use strict'
const
path
=
require
(
'path'
)
const
path
=
require
(
'path'
)
const
webpack
=
require
(
'webpack'
)
function
resolve
(
dir
)
{
function
resolve
(
dir
)
{
return
path
.
join
(
__dirname
,
dir
)
return
path
.
join
(
__dirname
,
dir
)
}
}
...
@@ -61,12 +61,23 @@ module.exports = {
...
@@ -61,12 +61,23 @@ module.exports = {
},
},
},
},
},
},
configureWebpack
:
{
configureWebpack
(
config
)
{
resolve
:
{
config
.
resolve
.
alias
=
{
alias
:
{
'@'
:
resolve
(
'src'
),
'@'
:
resolve
(
'src'
),
}
},
},
if
(
process
.
env
.
NODE_ENV
!==
'development'
)
{
// cdn
if
(
env
.
_ISCDN
)
{
config
.
externals
=
{
vue
:
'Vue'
,
'element-ui'
:
'ELEMENT'
,
'vue-router'
:
'VueRouter'
,
vuex
:
'Vuex'
,
axios
:
'axios'
,
}
}
}
},
},
chainWebpack
(
config
)
{
chainWebpack
(
config
)
{
// 修复HMR
// 修复HMR
...
@@ -95,16 +106,12 @@ module.exports = {
...
@@ -95,16 +106,12 @@ module.exports = {
})
})
.
end
()
.
end
()
// 删除 moment 语言包
config
.
plugin
(
'ignore'
).
use
(
new
webpack
.
ContextReplacementPlugin
(
/moment
[/\\]
locale$/
,
/zh-cn$/
))
config
.
when
(
process
.
env
.
NODE_ENV
!==
'development'
,
(
config
)
=>
{
config
.
when
(
process
.
env
.
NODE_ENV
!==
'development'
,
(
config
)
=>
{
// cdn
// cdn
if
(
env
.
_ISCDN
)
{
if
(
env
.
_ISCDN
)
{
config
.
externals
=
{
vue
:
'vue'
,
'element-ui'
:
'element-ui'
,
'vue-router'
:
'vue-router'
,
vuex
:
'vuex'
,
axios
:
'axios'
,
}
const
cdn
=
{
const
cdn
=
{
// 访问https://unpkg.com/element-ui/lib/theme-chalk/index.css获取最新版本
// 访问https://unpkg.com/element-ui/lib/theme-chalk/index.css获取最新版本
css
:
[
css
:
[
...
@@ -113,8 +120,8 @@ module.exports = {
...
@@ -113,8 +120,8 @@ module.exports = {
],
],
js
:
[
js
:
[
'//cdn.bootcdn.net/ajax/libs/vue/2.6.10/vue.runtime.min.js'
,
'//cdn.bootcdn.net/ajax/libs/vue/2.6.10/vue.runtime.min.js'
,
'//cdn.bootcdn.net/ajax/libs/vue-router/3.5.3/vue-router.min.js'
,
'//cdn.bootcdn.net/ajax/libs/vuex/3.1.0/vuex.min.js'
,
'//cdn.bootcdn.net/ajax/libs/vuex/3.1.0/vuex.min.js'
,
'//cdn.bootcdn.net/ajax/libs/vue-router/3.5.3/vue-router.min.js'
,
'//cdn.bootcdn.net/ajax/libs/axios/0.26.0/axios.min.js'
,
'//cdn.bootcdn.net/ajax/libs/axios/0.26.0/axios.min.js'
,
'//cdn.bootcdn.net/ajax/libs/element-ui/2.15.7/index.min.js'
,
'//cdn.bootcdn.net/ajax/libs/element-ui/2.15.7/index.min.js'
,
// '//unpkg.com/vue@2.6.10/dist/vue.runtime.min.js', // 访问https://unpkg.com/vue/dist/vue.min.js获取最新版本
// '//unpkg.com/vue@2.6.10/dist/vue.runtime.min.js', // 访问https://unpkg.com/vue/dist/vue.min.js获取最新版本
...
@@ -158,11 +165,11 @@ module.exports = {
...
@@ -158,11 +165,11 @@ module.exports = {
priority
:
10
,
priority
:
10
,
chunks
:
'initial'
,
// only package third parties that are initially dependent
chunks
:
'initial'
,
// only package third parties that are initially dependent
},
},
elementUI
:
{
//
elementUI: {
name
:
'chunk-elementUI'
,
// split elementUI into a single package
//
name: 'chunk-elementUI', // split elementUI into a single package
priority
:
20
,
// the weight needs to be larger than libs and app or it will be packaged into libs or app
//
priority: 20, // the weight needs to be larger than libs and app or it will be packaged into libs or app
test
:
/
[\\/]
node_modules
[\\/]
_
?
element-ui
(
.*
)
/
,
// in order to adapt to cnpm
//
test: /[\\/]node_modules[\\/]_?element-ui(.*)/, // in order to adapt to cnpm
},
//
},
commons
:
{
commons
:
{
name
:
'chunk-commons'
,
name
:
'chunk-commons'
,
test
:
resolve
(
'src/components'
),
// can customize your rules
test
:
resolve
(
'src/components'
),
// can customize your rules
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment