forked from dcloudio/uni-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.test.js
48 lines (40 loc) · 1.58 KB
/
webpack.config.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const path = require('path')
const webpack = require('webpack')
const resolve = dir => path.resolve(__dirname, '../', dir)
const pkg = require('../package.json')
let service = process.VUE_CLI_SERVICE
if (!service || process.env.VUE_CLI_API_MODE) {
const Service = require('@vue/cli-service')
service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd())
service.init(process.env.VUE_CLI_MODE || process.env.NODE_ENV)
}
const config = service.resolveWebpackConfig()
config.resolve.alias = {
'@': resolve('src'),
'uni-core': resolve('src/core'),
'uni-view': resolve('src/core/view'),
'uni-service': resolve('src/core/service'),
'uni-shared': resolve('src/shared'),
'uni-mixins': resolve('src/core/view/mixins'),
'uni-helpers': resolve('src/core/helpers'),
'uni-platform': resolve('src/platforms/' + process.env.UNI_PLATFORM),
'uni-components': resolve('src/core/view/components')
}
const isEslintLoader = config.module.rules[config.module.rules.length - 1].enforce
if (isEslintLoader) {
config.module.rules.splice(config.module.rules.length - 1, 1)
} else {
throw new Error('eslint-loader is undefined')
}
config.plugins = config.plugins.concat([
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkg.version),
__PLATFORM__: JSON.stringify(process.env.UNI_PLATFORM)
}),
new webpack.ProvidePlugin({
'console': [resolve('src/core/helpers/console'), 'default'],
'UniViewJSBridge': [resolve('src/core/view/bridge')],
'UniServiceJSBridge': [resolve('src/core/service/bridge')]
})
])
module.exports = config