From dcca490618ccd7e804f01f7a232ce4fa9054eec8 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Fri, 3 May 2024 16:01:51 +0000 Subject: [PATCH 1/3] Add webpack config for prod --- app/package.json | 2 +- app/webpack.prod.config.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 app/webpack.prod.config.js diff --git a/app/package.json b/app/package.json index 25aa2764b0..c42a923336 100644 --- a/app/package.json +++ b/app/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "build": "webpack", - "build:prod": "webpack --mode=production", + "build:prod": "webpack --config ./webpack.prod.config.js", "clean": "rimraf build && jlpm run clean:static", "clean:static": "rimraf -g \"../notebook/static/!(favicons)\"", "watch": "webpack --config ./webpack.config.watch.js" diff --git a/app/webpack.prod.config.js b/app/webpack.prod.config.js new file mode 100644 index 0000000000..025b532242 --- /dev/null +++ b/app/webpack.prod.config.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) Jupyter Development Team. + * Distributed under the terms of the Modified BSD License. + */ + +const merge = require('webpack-merge').default; +const config = require('./webpack.config'); +const WPPlugin = require('@jupyterlab/builder').WPPlugin; + +config[0] = merge(config[0], { + mode: 'production', + devtool: 'source-map', + output: { + // Add version argument when in production so the Jupyter server + // allows caching of files (i.e., does not set the CacheControl header to no-cache to prevent caching static files) + filename: '[name].[contenthash].js?v=[contenthash]' + }, + optimization: { + minimize: false + }, + plugins: [ + new WPPlugin.JSONLicenseWebpackPlugin({ + excludedPackageTest: packageName => + packageName === '@jupyterlab/application-top' + }) + ] +}); + +module.exports = config; From 925e5aa516beebf69ecdc24ee6139336b2812c6e Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Fri, 3 May 2024 16:05:09 +0000 Subject: [PATCH 2/3] add optimization --- app/webpack.config.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/webpack.config.js b/app/webpack.config.js index 4fdd9e5106..8707845b0b 100644 --- a/app/webpack.config.js +++ b/app/webpack.config.js @@ -214,7 +214,18 @@ module.exports = [ type: 'var', name: ['_JUPYTERLAB', 'CORE_OUTPUT'], }, - filename: 'bundle.js', + filename: '[name].[contenthash].js', + }, + optimization: { + splitChunks: { + chunks: 'all', + cacheGroups: { + jlab_core: { + test: /[\\/]node_modules[\\/]@(jupyterlab|jupyter-notebook|lumino(?!\/datagrid))[\\/]/, + name: 'notebook_core', + }, + }, + }, }, resolve: { fallback: { util: false }, From 4fb347a6eeec6a381a0323259ed0d33c529a4748 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Fri, 3 May 2024 16:06:13 +0000 Subject: [PATCH 3/3] rename top package --- app/webpack.prod.config.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/webpack.prod.config.js b/app/webpack.prod.config.js index 025b532242..db7e6dfdb5 100644 --- a/app/webpack.prod.config.js +++ b/app/webpack.prod.config.js @@ -13,17 +13,17 @@ config[0] = merge(config[0], { output: { // Add version argument when in production so the Jupyter server // allows caching of files (i.e., does not set the CacheControl header to no-cache to prevent caching static files) - filename: '[name].[contenthash].js?v=[contenthash]' + filename: '[name].[contenthash].js?v=[contenthash]', }, optimization: { - minimize: false + minimize: false, }, plugins: [ new WPPlugin.JSONLicenseWebpackPlugin({ - excludedPackageTest: packageName => - packageName === '@jupyterlab/application-top' - }) - ] + excludedPackageTest: (packageName) => + packageName === '@jupyter-notebook/app', + }), + ], }); module.exports = config;