-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
91 lines (90 loc) · 2.36 KB
/
Copy pathwebpack.config.js
File metadata and controls
91 lines (90 loc) · 2.36 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
const path = require("path");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const GlobEntries = require("webpack-glob-entries");
const webpack = require("webpack");
module.exports = {
mode: "production",
entry: GlobEntries("./tests-k6/**/*.test.ts"), // Generates multiple entry for each test
output: {
path: path.join(__dirname, "dist", "tests-k6"),
libraryTarget: "commonjs",
filename: "[name].js",
},
resolve: {
extensions: [".ts", ".js"],
alias: {
"@config": path.resolve(__dirname, "src", "config"),
"@constants": path.resolve(__dirname, "src", "constants"),
"@controllers": path.resolve(__dirname, "src", "api", "controllers"),
"@models": path.resolve(__dirname, "src", "api", "models"),
"@pages": path.resolve(__dirname, "src", "pages"),
"@utils": path.resolve(__dirname, "src", "utils"),
},
},
module: {
rules: [
{
test: /\.ts$/,
use: "babel-loader",
exclude: /node_modules/,
},
{
test: /\.png$/,
type: "asset/resource",
},
{
test: /\.html$/,
type: "asset/resource",
},
{
test: /\.css$/,
type: "asset/resource",
},
{
loader: "string-replace-loader",
options: {
search: "process.env.",
replace: "__ENV.",
flags: "g",
},
},
],
},
target: "web",
externals: [
// /^(k6|https?:\/\/)(\/.*)?/,
function ({ context, request }, c) {
if (request.startsWith("k6") || request.startsWith("https://")) {
return request === "k6-junit" ? c() : c(null, "commonjs " + request);
}
return c();
},
],
// Generate map files for compiled scripts
devtool: "source-map",
stats: {
colors: true,
},
plugins: [
new CleanWebpackPlugin(),
// Copy assets to the destination folder
// see `src/post-file-test.ts` for test example using an asset
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, "assets"),
noErrorOnMissing: true,
},
],
}),
// fix "process is not defined" error:
new webpack.ProvidePlugin({
process: "process/browser",
}),
],
optimization: {
// Don't minimize, as it's not used in the browser
minimize: false,
},
};