Don't use webpack chunkhash / name (only contenthash) (#8988)

* Don't use webpack chunkhash / name (only contenthash)

* Re-add hashFunction (keep as-is: explicit)

* Ensure main/runtime has named chunks

* Clarify shortcuts

* Adjust upper size (no impact, possibly future)
This commit is contained in:
Jaco 2023-02-09 13:51:42 +02:00 committed by GitHub
parent 886c23679e
commit 19f69c0d49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -25,7 +25,7 @@
],
"main": "packages/apps-electron/build/electron.js",
"scripts": {
"analyze": "yarn clean && BUILD_ANALYZE=1 yarn run build:code && yarn source-map-explorer packages/apps/build/main.*.js",
"analyze": "yarn clean && BUILD_ANALYZE=1 yarn run build:code && yarn source-map-explorer packages/apps/build/app.*.js",
"build": "yarn run build:i18n && yarn run build:code",
"build:code": "NODE_ENV=production yarn polkadot-dev-build-ts",
"build:devElectronMain": "cd packages/apps-electron && yarn polkadot-exec-webpack --config webpack.main.cjs",

View File

@ -71,7 +71,7 @@ function createWebpack (context, mode = 'production') {
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
type: 'asset/resource',
generator: {
filename: 'static/[name].[contenthash:8].[ext]'
filename: 'res.[contenthash].[ext]'
}
},
{
@ -79,7 +79,7 @@ function createWebpack (context, mode = 'production') {
test: [/\.eot$/, /\.ttf$/, /\.svg$/, /\.woff$/, /\.woff2$/],
type: 'asset/resource',
generator: {
filename: 'static/[name].[contenthash:8].[ext]'
filename: 'res.[contenthash].[ext]'
}
},
{
@ -111,7 +111,7 @@ function createWebpack (context, mode = 'production') {
[`cacheGroup${index}`]: {
chunks: 'initial',
enforce: true,
maxSize: 1_300_000,
maxSize: 1_500_000,
minSize: 0,
priority: -1 * index,
test
@ -121,8 +121,13 @@ function createWebpack (context, mode = 'production') {
}
},
output: {
chunkFilename: '[name].[chunkhash:8].js',
filename: '[name].[contenthash:8].js',
// this is for dynamic imports
chunkFilename: 'dyn.[contenthash].js',
// this is via splitChunks
filename: ({ chunk: { name } }) =>
['main', 'runtime'].includes(name)
? `${name === 'main' ? 'app' : 'run'}.[contenthash].js`
: 'mod.[contenthash].js',
globalObject: '(typeof self !== \'undefined\' ? self : this)',
hashFunction: 'xxhash64',
path: path.join(context, 'build'),
@ -149,7 +154,7 @@ function createWebpack (context, mode = 'production') {
}),
new webpack.optimize.SplitChunksPlugin(),
new MiniCssExtractPlugin({
filename: '[name].[contenthash:8].css'
filename: 'res.[contenthash].css'
})
].concat(plugins),
resolve: {