MCPcopy Index your code
hub / github.com/toeverything/AFFiNE / createHTMLTargetConfig

Function createHTMLTargetConfig

tools/cli/src/webpack/index.ts:45–374  ·  view source on GitHub ↗
(
  pkg: Package,
  entry: string | Record<string, string>,
  htmlConfig: Partial<CreateHTMLPluginConfig> = {},
  deps?: string[]
)

Source from the content-addressed store, hash-verified

43}
44
45export function createHTMLTargetConfig(
46 pkg: Package,
47 entry: string | Record<string, string>,
48 htmlConfig: Partial<CreateHTMLPluginConfig> = {},
49 deps?: string[]
50): webpack.Configuration {
51 entry = typeof entry === 'string' ? { index: entry } : entry;
52
53 htmlConfig = merge(
54 {},
55 {
56 filename: 'index.html',
57 additionalEntryForSelfhost: true,
58 injectGlobalErrorHandler: true,
59 emitAssetsManifest: true,
60 },
61 htmlConfig
62 );
63
64 const buildConfig = getBuildConfigFromEnv(pkg);
65
66 console.log(
67 `Building [${pkg.name}] for [${buildConfig.appBuildType}] channel in [${buildConfig.debug ? 'development' : 'production'}] mode.`
68 );
69 console.log(
70 `Entry points: ${Object.entries(entry)
71 .map(([name, path]) => `${name}: ${path}`)
72 .join(', ')}`
73 );
74 console.log(`Output path: ${pkg.distPath.value}`);
75 console.log(`Config: ${JSON.stringify(buildConfig, null, 2)}`);
76
77 const config: webpack.Configuration = {
78 //#region basic webpack config
79 name: entry['index'],
80 dependencies: deps,
81 context: ProjectRoot.value,
82 experiments: {
83 topLevelAwait: true,
84 outputModule: false,
85 syncWebAssembly: true,
86 },
87 entry,
88 output: {
89 environment: { module: true, dynamicImport: true },
90 filename: buildConfig.debug
91 ? 'js/[name].js'
92 : 'js/[name].[contenthash:8].js',
93 assetModuleFilename: buildConfig.debug
94 ? '[name].[contenthash:8][ext]'
95 : 'assets/[name].[contenthash:8][ext][query]',
96 path: pkg.distPath.value,
97 clean: false,
98 globalObject: 'globalThis',
99 // NOTE(@forehalo): always keep it '/'
100 publicPath: '/',
101 },
102 target: ['web', 'es2022'],

Callers

nothing calls this directly

Calls 9

createHTMLPluginsFunction · 0.85
mapMethod · 0.80
stringifyMethod · 0.80
getBuildConfigFromEnvFunction · 0.70
mergeFunction · 0.50
logMethod · 0.45
joinMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected