diff --git a/packages/next/build/webpack.js b/packages/next/build/webpack.js index cc9a8ccd..da209b03 100644 --- a/packages/next/build/webpack.js +++ b/packages/next/build/webpack.js @@ -94,11 +94,19 @@ function optimizationConfig ({dir, dev, isServer, totalPages}) { } // Terser is a better uglifier - config.minimizer = [new TerserPlugin({ - parallel: true, - sourceMap: false, - cache: true - })] + config.minimizer = [ + new TerserPlugin({ + parallel: true, + sourceMap: false, + cache: true, + cacheKeys: (keys) => { + // path changes per build because we add buildId + // because the input is already hashed the path is not needed + delete keys.path + return keys + } + }) + ] // Only enabled in production // This logic will create a commons bundle @@ -268,6 +276,7 @@ export default async function getBaseWebpackConfig (dir: string, {dev = false, i dev && new webpack.NoEmitOnErrorsPlugin(), dev && new UnlinkFilePlugin(), dev && new CaseSensitivePathPlugin(), // Since on macOS the filesystem is case-insensitive this will make sure your path are case-sensitive + !dev && new webpack.HashedModuleIdsPlugin(), // Removes server/client code by minifier new webpack.DefinePlugin({ 'process.browser': JSON.stringify(!isServer) diff --git a/packages/next/build/webpack/loaders/next-babel-loader.js b/packages/next/build/webpack/loaders/next-babel-loader.js index 9f87a9b1..6d7a0c2d 100644 --- a/packages/next/build/webpack/loaders/next-babel-loader.js +++ b/packages/next/build/webpack/loaders/next-babel-loader.js @@ -12,6 +12,7 @@ module.exports = babelLoader.custom(babel => { dev: opts.dev } const loader = Object.assign({ + cacheCompression: false, cacheDirectory: true }, opts) delete loader.isServer diff --git a/test/integration/size-limit/test/index.test.js b/test/integration/size-limit/test/index.test.js index 56d628ed..657a3c15 100644 --- a/test/integration/size-limit/test/index.test.js +++ b/test/integration/size-limit/test/index.test.js @@ -66,6 +66,6 @@ describe('Production response size', () => { console.log(`Response Sizes:\n${responseSizes.map(obj => ` ${obj.url}: ${obj.bytes} (bytes)`).join('\n')} \nOverall: ${responseSizeKilobytes} KB`) // These numbers are without gzip compression! - expect(responseSizeKilobytes).toBeLessThanOrEqual(203) // Kilobytes + expect(responseSizeKilobytes).toBeLessThanOrEqual(207) // Kilobytes }) })