@@ -15,6 +15,7 @@ const BundleAnalyzerPlugin =
1515
1616const Build = require ( '@jupyterlab/builder' ) . Build ;
1717const WPPlugin = require ( '@jupyterlab/builder' ) . WPPlugin ;
18+ const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
1819const baseConfig = require ( '@jupyterlab/builder/lib/webpack.config.base' ) ;
1920
2021const data = require ( './package.json' ) ;
@@ -204,22 +205,55 @@ if (process.argv.includes('--analyze')) {
204205 extras . push ( new BundleAnalyzerPlugin ( ) ) ;
205206}
206207
208+ const htmlPlugins = [ ] ;
209+ [ 'consoles' , 'edit' , 'error' , 'notebooks' , 'terminals' , 'tree' ] . forEach (
210+ ( name ) => {
211+ htmlPlugins . push (
212+ new HtmlWebpackPlugin ( {
213+ chunksSortMode : 'none' ,
214+ template : path . join (
215+ path . resolve ( './templates' ) ,
216+ `${ name } _template.html`
217+ ) ,
218+ title : name ,
219+ filename : path . join (
220+ path . resolve ( __dirname , '..' , 'notebook/templates' ) ,
221+ `${ name } .html`
222+ ) ,
223+ } )
224+ ) ;
225+ }
226+ ) ;
227+
207228module . exports = [
208229 merge ( baseConfig , {
209230 mode : 'development' ,
210231 entry : [ './publicpath.js' , './' + path . relative ( __dirname , entryPoint ) ] ,
211232 output : {
212233 path : path . resolve ( __dirname , '..' , 'notebook/static/' ) ,
234+ publicPath : '{{page_config.fullStaticUrl}}/' ,
213235 library : {
214236 type : 'var' ,
215237 name : [ '_JUPYTERLAB' , 'CORE_OUTPUT' ] ,
216238 } ,
217- filename : 'bundle.js' ,
239+ filename : '[name].[contenthash].js' ,
240+ } ,
241+ optimization : {
242+ splitChunks : {
243+ chunks : 'all' ,
244+ cacheGroups : {
245+ jlab_core : {
246+ test : / [ \\ / ] n o d e _ m o d u l e s [ \\ / ] @ ( j u p y t e r l a b | j u p y t e r - n o t e b o o k | l u m i n o (? ! \/ d a t a g r i d ) ) [ \\ / ] / ,
247+ name : 'notebook_core' ,
248+ } ,
249+ } ,
250+ } ,
218251 } ,
219252 resolve : {
220253 fallback : { util : false } ,
221254 } ,
222255 plugins : [
256+ ...htmlPlugins ,
223257 new WPPlugin . JSONLicenseWebpackPlugin ( {
224258 excludedPackageTest : ( packageName ) =>
225259 packageName === '@jupyter-notebook/app' ,
@@ -235,3 +269,6 @@ module.exports = [
235269 ] ,
236270 } ) ,
237271] . concat ( extras ) ;
272+
273+ const logPath = path . join ( buildDir , 'build_log.json' ) ;
274+ fs . writeFileSync ( logPath , JSON . stringify ( module . exports , null , ' ' ) ) ;
0 commit comments