forked from theintern/intern
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack-tests.config.ts
More file actions
91 lines (81 loc) · 2.14 KB
/
webpack-tests.config.ts
File metadata and controls
91 lines (81 loc) · 2.14 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { join } from 'path';
import { Configuration, HotModuleReplacementPlugin } from 'webpack';
import TsconfigPathsPlugin from 'tsconfig-paths-webpack-plugin';
import { sync as glob } from 'glob';
import { getConfig } from './src/core/lib/node/util';
// @ts-ignore
import RewireMockPlugin from 'rewiremock/webpack/plugin';
const common: Configuration = {
externals: {
intern: 'intern'
},
// Needed for rewiremock
mode: 'development',
module: {
rules: [
{
test: /\.styl$/,
use: ['style-loader', 'css-loader', 'stylus-loader']
},
{
test: /\.ts/,
use: {
loader: 'ts-loader',
options: {
silent: true,
configFile: 'tsconfig-tests.json',
onlyCompileBundledFiles: true
}
}
}
],
// benchmark's code makes webpack sad; tell webpack not to look at it
noParse: /benchmark\.js/
},
performance: {
// Hides a warning about large bundles.
hints: false
},
plugins: [
// Needed for mocking
new HotModuleReplacementPlugin(),
// Needed for mocking
new RewireMockPlugin()
],
resolve: {
extensions: ['.ts', '.js'],
// Needed to resolve 'tests/' and '/src' imports in test modules
plugins: [new TsconfigPathsPlugin()]
},
stats: 'errors-warnings'
};
module.exports = getEntries().then(entries => [
{
...common,
entry: entries,
output: {
filename: '[name].js',
path: join(__dirname, '_tests')
}
}
]);
async function getEntries() {
const { config } = await getConfig();
const configSuites: string[] = config.suites || [];
if (config.browser && config.browser.suites) {
configSuites.push(...config.browser.suites);
}
const suites = configSuites.reduce(
(files, pattern) => [
...files,
...glob(pattern).map(file => join('.', file))
],
[] as string[]
);
const configPlugins: { script: string }[] = config.plugins || [];
if (config.browser && config.browser.plugins) {
configPlugins.push(...config.browser.plugins);
}
const plugins = configPlugins.map(plugin => plugin.script);
return { suites, plugins };
}