Repository navigation
Expand file tree
/
Copy pathcypress.preprocessor.js
More file actions
65 lines (62 loc) · 1.66 KB
/
Copy pathcypress.preprocessor.js
File metadata and controls
65 lines (62 loc) · 1.66 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
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
const webpackPreprocessor = require("@cypress/webpack-preprocessor");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const webpack = require("webpack");
function registerCypressPreprocessor(on, tsConfig) {
on(
"file:preprocessor",
webpackPreprocessor({
webpackOptions: {
mode: "development",
module: {
rules: [
{
test: /\.[jt]sx?$/,
exclude: /node_modules/,
use: {
loader: "ts-loader",
options: {
configFile: tsConfig,
transpileOnly: true
}
}
},
{
test: /\.css$/,
use: "null-loader"
}
]
},
plugins: [
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
process: "process/browser"
})
],
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
fallback: {
assert: require.resolve("assert/"),
child_process: false,
dgram: false,
dns: false,
fs: false,
http2: false,
module: false,
net: false,
stream: require.resolve("stream-browserify"),
tls: false,
url: require.resolve("url/")
},
plugins: [
new TsconfigPathsPlugin({
configFile: tsConfig
})
]
}
}
})
);
}
module.exports = { registerCypressPreprocessor };