mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +00:00
Update webpack.cjs
This commit is contained in:
parent
0a55220837
commit
431f4937c1
@ -10,6 +10,7 @@ const WebpackBar = require("webpackbar");
|
|||||||
const {
|
const {
|
||||||
TransformAsyncModulesPlugin,
|
TransformAsyncModulesPlugin,
|
||||||
} = require("transform-async-modules-webpack-plugin");
|
} = require("transform-async-modules-webpack-plugin");
|
||||||
|
const { dependencies } = require("../package.json");
|
||||||
const paths = require("./paths.cjs");
|
const paths = require("./paths.cjs");
|
||||||
const bundle = require("./bundle.cjs");
|
const bundle = require("./bundle.cjs");
|
||||||
|
|
||||||
@ -147,16 +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({ browserslistEnv: "legacy" }),
|
new TransformAsyncModulesPlugin({
|
||||||
|
browserslistEnv: "legacy",
|
||||||
|
runtime: { version: dependencies["@babel/runtime"] },
|
||||||
|
}),
|
||||||
].filter(Boolean),
|
].filter(Boolean),
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".ts", ".js", ".json"],
|
extensions: [".ts", ".js", ".json"],
|
||||||
@ -207,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,
|
||||||
])
|
])
|
||||||
),
|
),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user