Skip to content

Commit

Permalink
🐛 Fix unoptimized webpack module output
Browse files Browse the repository at this point in the history
  • Loading branch information
williamchong committed Sep 11, 2023
1 parent 2538790 commit 7092f9f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
15 changes: 6 additions & 9 deletions src/IndexHTML.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,11 @@ export default class IndexHTML extends React.Component {
<meta content="oice" name="apple-mobile-web-app-title" />

<title>{meta.title}</title>
<link rel="preload" href={`/build/manifest.js?v=${VERSION}`} as="script" />
<link rel="preload" href={`/build/vendor.css?v=${VERSION}`} as="style" />
<link rel="preload" href={`/build/common.css?v=${VERSION}`} as="style" />
<link rel="preload" href={`/build/${module}.css?v=${VERSION}`} as="style" />
<link rel="preload" href={`/build/vendor.js?v=${VERSION}`} as="script" />
<link rel="preload" href={`/build/common.js?v=${VERSION}`} as="script" />
<link rel="preload" href={`/build/${module}.css?v=${VERSION}`} as="style" />
{modules.map(m => (
<link
key={m}
Expand All @@ -106,13 +107,13 @@ export default class IndexHTML extends React.Component {
/>
))}

{!DEBUG &&
{!DEBUG && ['vendor', 'common', module].map(m => (
<link
href={`/build/${module}.css?v=${VERSION}`}
href={`/build/${m}.css?v=${VERSION}`}
rel="stylesheet"
type="text/css"
/>
}
))}
<link
href="/img/favicon.ico"
rel="shortcut icon"
Expand Down Expand Up @@ -144,10 +145,6 @@ export default class IndexHTML extends React.Component {
<div id="app" className={className}>
{children}
</div>
<script
src={`/build/manifest.js?v=${VERSION}`}
type="application/javascript"
/>
<script
src={`/build/vendor.js?v=${VERSION}`}
type="application/javascript"
Expand Down
20 changes: 18 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,24 @@ module.exports = {
path: BUILD_DIR,
publicPath: `/${BUILD_DIR_NAME}/`,
},
optimization: {
minimize: !DEBUG,
splitChunks: {
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendor',
chunks: 'all',
},
common: {
chunks: 'all',
name: 'common',
minChunks: 2,
},
},
},
runtimeChunk: false,
},
performance: {
maxEntrypointSize: 1000000,
maxAssetSize: 300000,
Expand Down Expand Up @@ -157,8 +175,6 @@ module.exports = {
new webpack.HotModuleReplacementPlugin(),
] : [
// Production
new webpack.HashedModuleIdsPlugin(),
new webpack.DefinePlugin({ 'global.GENTLY': false }),
new webpack.optimize.ModuleConcatenationPlugin(),
]),
};

0 comments on commit 7092f9f

Please sign in to comment.