Skip to content

Commit 706abef

Browse files
author
郑傲今
committed
fix: Global variables and mock
1 parent 3004333 commit 706abef

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module.exports = {
1414
JSBridge : true,
1515
window : true,
1616
document : true,
17-
wx : true
17+
wx : true,
18+
__ENV__ : true
1819
},
1920
parserOptions: {
2021
sourceType : 'module',

config/webpack.base.config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
44
const IncludeAssetsPlugin = require('html-webpack-include-assets-plugin')
55
const ESLintFormatter = require('eslint-friendly-formatter')
66
const {
7+
env,
78
esLint,
89
basePath,
910
srcDir,
@@ -102,6 +103,9 @@ const base = {
102103
hints: false
103104
},
104105
plugins: [
106+
new webpack.DefinePlugin({
107+
__ENV__: JSON.stringify(env)
108+
}),
105109
new webpack.DllReferencePlugin({
106110
context : basePath,
107111
manifest: path.resolve(basePath, 'dll', 'manifest.json')

project.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = {
1313
'border-radius-sm' : '2px',
1414
'font-family' : 'Microsoft YaHei'
1515
},
16+
env : NODE_ENV,
1617
basePath : __dirname,
1718
srcDir : path.resolve(__dirname, 'src'),
1819
outDir : path.resolve(__dirname, 'dist'),

src/service/api/mock.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const domain = __ENV__ === 'production' ? 'https://www.easy-mock.com' : ''
2+
13
export default {
2-
LOGIN: '/mock/5c4989d06498891c5bff820d/rsk/login'
4+
LOGIN: `${domain}/mock/5c4989d06498891c5bff820d/rsk/login`
35
}

0 commit comments

Comments
 (0)