forked from vuejs/vue-test-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.test.config.js
60 lines (57 loc) · 1.51 KB
/
webpack.test.config.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
49
50
51
52
53
54
55
56
57
58
59
60
/* eslint-disable max-len */
const nodeExternals = require('webpack-node-externals')
const webpack = require('webpack')
const browser = process.env.TARGET === 'browser'
const path = require('path')
const projectRoot = path.resolve(__dirname, '../../')
const rules = [].concat(
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}
)
const externals = nodeExternals({
// we need to allowlist both `create-instance` and files in `shared` package. Otherwise webpack won't bundle them in the test dev env
allowlist: [
'@vue/test-utils',
'@vue/server-test-utils',
'create-instance',
/^shared\/.*/
]
})
// define the default aliases
let aliasedFiles = {}
if (process.env.TARGET === 'dev') {
// if we are in dev test mode, we want to alias all files to the src file, not dist
aliasedFiles = {
'@vue/server-test-utils': `@vue/server-test-utils/src/index.js`,
'@vue/test-utils': `@vue/test-utils/src/index.js`
}
}
module.exports = {
module: {
rules
},
externals: !browser ? [externals] : undefined,
resolve: {
alias: {
...aliasedFiles,
'~resources': `${projectRoot}/test/resources`
}
},
output: {
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]'
},
devtool: '#inline-cheap-module-source-map',
node: {
fs: 'empty',
module: 'empty'
},
plugins: [new webpack.EnvironmentPlugin(['TEST_ENV'])]
}