format webpack.cjs

pull/20901/head
Bram Kragten 2024-05-29 18:04:24 +02:00
parent 431f4937c1
commit c0e048023d
1 changed files with 23 additions and 23 deletions

View File

@ -148,19 +148,19 @@ const createWebpackConfig = ({
), ),
!isProdBuild && new LogStartCompilePlugin(), !isProdBuild && new LogStartCompilePlugin(),
isProdBuild && isProdBuild &&
new StatsWriterPlugin({ new StatsWriterPlugin({
filename: path.relative( filename: path.relative(
outputPath, outputPath,
path.join(paths.build_dir, "stats", `${name}.json`) path.join(paths.build_dir, "stats", `${name}.json`)
), ),
stats: { assets: true, chunks: true, modules: true }, stats: { assets: true, chunks: true, modules: true },
transform: (stats) => JSON.stringify(filterStats(stats)), transform: (stats) => JSON.stringify(filterStats(stats)),
}), }),
!latestBuild && !latestBuild &&
new TransformAsyncModulesPlugin({ new TransformAsyncModulesPlugin({
browserslistEnv: "legacy", browserslistEnv: "legacy",
runtime: { version: dependencies["@babel/runtime"] }, runtime: { version: dependencies["@babel/runtime"] },
}), }),
].filter(Boolean), ].filter(Boolean),
resolve: { resolve: {
extensions: [".ts", ".js", ".json"], extensions: [".ts", ".js", ".json"],
@ -211,18 +211,18 @@ const createWebpackConfig = ({
`devtool${v}ModuleFilenameTemplate`, `devtool${v}ModuleFilenameTemplate`,
!isTestBuild && isProdBuild !isTestBuild && isProdBuild
? (info) => { ? (info) => {
if ( if (
!path.isAbsolute(info.absoluteResourcePath) || !path.isAbsolute(info.absoluteResourcePath) ||
!existsSync(info.resourcePath) || !existsSync(info.resourcePath) ||
info.resourcePath.startsWith("./node_modules") info.resourcePath.startsWith("./node_modules")
) { ) {
// Source URLs are unknown for dependencies, so we use a relative URL with a // Source URLs are unknown for dependencies, so we use a relative URL with a
// non - existent top directory. This results in a clean source tree in browser // non - existent top directory. This results in a clean source tree in browser
// dev tools, and they stay happy getting 404s with valid requests. // dev tools, and they stay happy getting 404s with valid requests.
return `/unknown${path.resolve("/", info.resourcePath)}`; return `/unknown${path.resolve("/", info.resourcePath)}`;
}
return new URL(info.resourcePath, bundle.sourceMapURL()).href;
} }
return new URL(info.resourcePath, bundle.sourceMapURL()).href;
}
: undefined, : undefined,
]) ])
), ),