Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
marketing
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
marketing-web
marketing
Commits
6ac3270c
Commit
6ac3270c
authored
Apr 25, 2019
by
chenxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:webpack跨域配置
parent
8a8be75a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
67 deletions
+63
-67
webpack.base.conf.js
build/webpack.base.conf.js
+18
-20
webpack.dev.conf.js
build/webpack.dev.conf.js
+32
-36
dev.env.js
config/dev.env.js
+4
-4
index.js
config/index.js
+7
-7
index.js
src/config/index.js
+2
-0
No files found.
build/webpack.base.conf.js
View file @
6ac3270c
'use strict'
'use strict'
;
const
path
=
require
(
'path'
)
const
path
=
require
(
'path'
)
;
const
utils
=
require
(
'./utils'
)
const
utils
=
require
(
'./utils'
)
;
const
config
=
require
(
'../config'
)
const
config
=
require
(
'../config'
)
;
const
vueLoaderConfig
=
require
(
'./vue-loader.conf'
)
const
vueLoaderConfig
=
require
(
'./vue-loader.conf'
)
;
function
resolve
(
dir
)
{
function
resolve
(
dir
)
{
return
path
.
join
(
__dirname
,
'..'
,
dir
)
return
path
.
join
(
__dirname
,
'..'
,
dir
)
;
}
}
const
createLintingRule
=
()
=>
({
const
createLintingRule
=
()
=>
({
test
:
/
\.(
js|vue
)
$/
,
test
:
/
\.(
js|vue
)
$/
,
loader
:
"eslint-loader"
,
loader
:
'eslint-loader'
,
enforce
:
"pre"
,
enforce
:
'pre'
,
include
:
[
resolve
(
"src"
),
resolve
(
"test"
)],
include
:
[
resolve
(
'src'
),
resolve
(
'test'
)],
options
:
{
options
:
{
// fix: true,
// fix: true,
formatter
:
require
(
"eslint-friendly-formatter"
),
formatter
:
require
(
'eslint-friendly-formatter'
),
emitWarning
:
!
config
.
dev
.
showEslintErrorsInOverlay
emitWarning
:
!
config
.
dev
.
showEslintErrorsInOverlay
}
}
});
});
module
.
exports
=
{
module
.
exports
=
{
context
:
path
.
resolve
(
__dirname
,
'../'
),
context
:
path
.
resolve
(
__dirname
,
'../'
),
entry
:
[
'babel-polyfill'
,
'./src/main.js'
],
entry
:
[
'babel-polyfill'
,
'./src/main.js'
],
output
:
{
output
:
{
path
:
config
.
build
.
assetsRoot
,
path
:
config
.
build
.
assetsRoot
,
filename
:
'[name].js'
,
filename
:
'[name].js'
,
publicPath
:
process
.
env
.
NODE_ENV
===
'production'
publicPath
:
process
.
env
.
NODE_ENV
===
'production'
?
config
.
build
.
assetsPublicPath
:
config
.
dev
.
assetsPublicPath
?
config
.
build
.
assetsPublicPath
:
config
.
dev
.
assetsPublicPath
},
},
resolve
:
{
resolve
:
{
extensions
:
[
'.js'
,
'.vue'
,
'.json'
],
extensions
:
[
'.js'
,
'.vue'
,
'.json'
],
alias
:
{
alias
:
{
'vue$'
:
'vue/dist/vue.esm.js'
,
vue
$
:
'vue/dist/vue.esm.js'
,
'@'
:
resolve
(
'src'
)
,
'@'
:
resolve
(
'src'
)
}
}
},
},
module
:
{
module
:
{
...
@@ -82,9 +80,9 @@ module.exports = {
...
@@ -82,9 +80,9 @@ module.exports = {
]
]
},
},
externals
:
{
externals
:
{
'vue'
:
'Vue'
,
vue
:
'Vue'
,
'vue-router'
:
'VueRouter'
,
'vue-router'
:
'VueRouter'
,
'vuex'
:
'Vuex'
,
vuex
:
'Vuex'
// 'axios': 'axios'
// 'axios': 'axios'
},
},
node
:
{
node
:
{
...
@@ -99,4 +97,4 @@ module.exports = {
...
@@ -99,4 +97,4 @@ module.exports = {
tls
:
'empty'
,
tls
:
'empty'
,
child_process
:
'empty'
child_process
:
'empty'
}
}
}
}
;
build/webpack.dev.conf.js
View file @
6ac3270c
'use strict'
'use strict'
;
const
utils
=
require
(
'./utils'
)
const
utils
=
require
(
'./utils'
)
;
const
webpack
=
require
(
'webpack'
)
const
webpack
=
require
(
'webpack'
)
;
const
config
=
require
(
'../config'
)
const
config
=
require
(
'../config'
)
;
const
merge
=
require
(
'webpack-merge'
)
const
merge
=
require
(
'webpack-merge'
)
;
const
path
=
require
(
'path'
)
const
path
=
require
(
'path'
)
;
const
baseWebpackConfig
=
require
(
'./webpack.base.conf'
)
const
baseWebpackConfig
=
require
(
'./webpack.base.conf'
)
;
const
CopyWebpackPlugin
=
require
(
'copy-webpack-plugin'
)
const
CopyWebpackPlugin
=
require
(
'copy-webpack-plugin'
)
;
const
HtmlWebpackPlugin
=
require
(
'html-webpack-plugin'
)
const
HtmlWebpackPlugin
=
require
(
'html-webpack-plugin'
)
;
const
FriendlyErrorsPlugin
=
require
(
'friendly-errors-webpack-plugin'
)
const
FriendlyErrorsPlugin
=
require
(
'friendly-errors-webpack-plugin'
)
;
const
portfinder
=
require
(
'portfinder'
)
const
portfinder
=
require
(
'portfinder'
)
;
const
HOST
=
process
.
env
.
HOST
const
HOST
=
process
.
env
.
HOST
;
const
PORT
=
process
.
env
.
PORT
&&
Number
(
process
.
env
.
PORT
)
const
PORT
=
process
.
env
.
PORT
&&
Number
(
process
.
env
.
PORT
)
;
const
devWebpackConfig
=
merge
(
baseWebpackConfig
,
{
const
devWebpackConfig
=
merge
(
baseWebpackConfig
,
{
module
:
{
module
:
{
...
@@ -24,9 +24,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
...
@@ -24,9 +24,7 @@ const devWebpackConfig = merge(baseWebpackConfig, {
devServer
:
{
devServer
:
{
clientLogLevel
:
'warning'
,
clientLogLevel
:
'warning'
,
historyApiFallback
:
{
historyApiFallback
:
{
rewrites
:
[
rewrites
:
[{
from
:
/.*/
,
to
:
path
.
posix
.
join
(
config
.
dev
.
assetsPublicPath
,
'index.html'
)
}]
{
from
:
/.*/
,
to
:
path
.
posix
.
join
(
config
.
dev
.
assetsPublicPath
,
'index.html'
)
},
],
},
},
hot
:
true
,
hot
:
true
,
contentBase
:
false
,
// since we use CopyWebpackPlugin.
contentBase
:
false
,
// since we use CopyWebpackPlugin.
...
@@ -34,14 +32,12 @@ const devWebpackConfig = merge(baseWebpackConfig, {
...
@@ -34,14 +32,12 @@ const devWebpackConfig = merge(baseWebpackConfig, {
host
:
HOST
||
config
.
dev
.
host
,
host
:
HOST
||
config
.
dev
.
host
,
port
:
PORT
||
config
.
dev
.
port
,
port
:
PORT
||
config
.
dev
.
port
,
open
:
config
.
dev
.
autoOpenBrowser
,
open
:
config
.
dev
.
autoOpenBrowser
,
overlay
:
config
.
dev
.
errorOverlay
overlay
:
config
.
dev
.
errorOverlay
?
{
warnings
:
false
,
errors
:
true
}
:
false
,
?
{
warnings
:
false
,
errors
:
true
}
:
false
,
publicPath
:
config
.
dev
.
assetsPublicPath
,
publicPath
:
config
.
dev
.
assetsPublicPath
,
proxy
:
config
.
dev
.
proxyTable
,
proxy
:
config
.
dev
.
proxyTable
,
quiet
:
true
,
// necessary for FriendlyErrorsPlugin
quiet
:
true
,
// necessary for FriendlyErrorsPlugin
watchOptions
:
{
watchOptions
:
{
poll
:
config
.
dev
.
poll
,
poll
:
config
.
dev
.
poll
}
}
},
},
plugins
:
[
plugins
:
[
...
@@ -66,30 +62,30 @@ const devWebpackConfig = merge(baseWebpackConfig, {
...
@@ -66,30 +62,30 @@ const devWebpackConfig = merge(baseWebpackConfig, {
}
}
])
])
]
]
})
})
;
module
.
exports
=
new
Promise
((
resolve
,
reject
)
=>
{
module
.
exports
=
new
Promise
((
resolve
,
reject
)
=>
{
portfinder
.
basePort
=
process
.
env
.
PORT
||
config
.
dev
.
port
portfinder
.
basePort
=
process
.
env
.
PORT
||
config
.
dev
.
port
;
portfinder
.
getPort
((
err
,
port
)
=>
{
portfinder
.
getPort
((
err
,
port
)
=>
{
if
(
err
)
{
if
(
err
)
{
reject
(
err
)
reject
(
err
)
;
}
else
{
}
else
{
// publish the new Port, necessary for e2e tests
// publish the new Port, necessary for e2e tests
process
.
env
.
PORT
=
port
process
.
env
.
PORT
=
port
;
// add port to devServer config
// add port to devServer config
devWebpackConfig
.
devServer
.
port
=
port
devWebpackConfig
.
devServer
.
port
=
port
;
// Add FriendlyErrorsPlugin
// Add FriendlyErrorsPlugin
devWebpackConfig
.
plugins
.
push
(
new
FriendlyErrorsPlugin
({
devWebpackConfig
.
plugins
.
push
(
compilationSuccessInfo
:
{
new
FriendlyErrorsPlugin
(
{
messages
:
[
`Your application is running here: http://
${
devWebpackConfig
.
devServer
.
host
}
:
${
port
}
`
],
compilationSuccessInfo
:
{
},
messages
:
[
`Your application is running here: http://
${
devWebpackConfig
.
devServer
.
host
}
:
${
port
}
`
]
onErrors
:
config
.
dev
.
notifyOnErrors
},
?
utils
.
createNotifierCallback
()
onErrors
:
config
.
dev
.
notifyOnErrors
?
utils
.
createNotifierCallback
()
:
undefined
:
undefined
})
}))
);
resolve
(
devWebpackConfig
)
resolve
(
devWebpackConfig
)
;
}
}
})
})
;
})
})
;
config/dev.env.js
View file @
6ac3270c
'use strict'
'use strict'
;
const
merge
=
require
(
'webpack-merge'
)
const
merge
=
require
(
'webpack-merge'
)
;
const
prodEnv
=
require
(
'./prod.env'
)
const
prodEnv
=
require
(
'./prod.env'
)
;
module
.
exports
=
merge
(
prodEnv
,
{
module
.
exports
=
merge
(
prodEnv
,
{
NODE_ENV
:
'"development"'
NODE_ENV
:
'"development"'
})
})
;
config/index.js
View file @
6ac3270c
...
@@ -10,13 +10,13 @@ module.exports = {
...
@@ -10,13 +10,13 @@ module.exports = {
assetsSubDirectory
:
'static'
,
assetsSubDirectory
:
'static'
,
assetsPublicPath
:
'/'
,
assetsPublicPath
:
'/'
,
proxyTable
:
{
proxyTable
:
{
// '/dmApi/':
{
'/dmApi/'
:
{
// target:'http://gicdev.demogic.com/
',
target
:
'http://192.168.1.154:86
'
,
// changeOrigin:
true,
changeOrigin
:
true
,
// pathRewrite:
{
pathRewrite
:
{
// '^/dmApi':
''
'^/dmApi'
:
''
//
}
}
//
}
}
},
},
// Various Dev Server settings
// Various Dev Server settings
...
...
src/config/index.js
View file @
6ac3270c
export
default
{
export
default
{
// eslint-disable-next-line
// eslint-disable-next-line
api
:
process
.
env
[
'NODE_ENV'
]
===
'development'
?
'http://gicdev.demogic.com/'
:
window
.
location
.
protocol
+
'//'
+
window
.
location
.
host
+
'/'
||
''
api
:
process
.
env
[
'NODE_ENV'
]
===
'development'
?
'http://gicdev.demogic.com/'
:
window
.
location
.
protocol
+
'//'
+
window
.
location
.
host
+
'/'
||
''
// http://gicdev.demogic.com/
// http://192.168.1.154:86/
};
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment