From a647dc334667d167d9347381f2401ee6d4182f9f Mon Sep 17 00:00:00 2001 From: Ryan Christian Date: Wed, 17 Aug 2022 05:13:21 -0500 Subject: [PATCH] junk: Kinda works but not really --- .../cli/lib/lib/webpack/webpack-base-config.js | 14 +++----------- .../cli/lib/lib/webpack/webpack-client-config.js | 10 +++++----- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/cli/lib/lib/webpack/webpack-base-config.js b/packages/cli/lib/lib/webpack/webpack-base-config.js index af0d2b746..84ee3b52a 100644 --- a/packages/cli/lib/lib/webpack/webpack-base-config.js +++ b/packages/cli/lib/lib/webpack/webpack-base-config.js @@ -292,16 +292,9 @@ module.exports = function createBaseConfig(env) { new MiniCssExtractPlugin({ filename: isProd && !env.isServer ? '[name].[contenthash:5].css' : '[name].css', - chunkFilename: pathData => { - const chunkId = /** @type {string} */ (pathData.chunk.id); - const chunkName = - typeof chunkId === 'string' - ? chunkId.split('_').slice(0, -1).join('-') - : chunkId; - return isProd - ? `${chunkName}.chunk.[chunkhash:5].css` - : `${chunkName}.chunk.css`; - }, + chunkFilename: isProd + ? '[name].chunk.[contenthash:5].css' + : '[name].chunk.css', }), ProgressBarPlugin({ format: @@ -328,7 +321,6 @@ module.exports = function createBaseConfig(env) { }, }, }), - isProd && new webpack.LoaderOptionsPlugin({ minimize: true }), new webpack.optimize.ModuleConcatenationPlugin(), // strip out babel-helper invariant checks diff --git a/packages/cli/lib/lib/webpack/webpack-client-config.js b/packages/cli/lib/lib/webpack/webpack-client-config.js index 56831d023..d9c2f89f2 100644 --- a/packages/cli/lib/lib/webpack/webpack-client-config.js +++ b/packages/cli/lib/lib/webpack/webpack-client-config.js @@ -23,6 +23,10 @@ const cleanFilename = name => '' ); +// TODO: Swap with the above when removing the async loader +const cleanFilename2 = name => + (name = name.replace(/_/g, '-').replace(/(-index|-[jt]sx?$)/, '')); + /** * @returns {Promise} */ @@ -88,11 +92,7 @@ async function clientConfig(env) { return env.isProd ? '[name].[chunkhash:5].js' : '[name].js'; }, chunkFilename: pathData => { - const chunkId = /** @type {string} */ (pathData.chunk.id); - const chunkName = - typeof chunkId === 'string' - ? chunkId.split('_').slice(0, -1).join('-') - : chunkId; + const chunkName = cleanFilename2(pathData.chunk.id); return env.isProd ? `${chunkName}.chunk.[chunkhash:5].js` : `${chunkName}.chunk.js`;