@@ -15,6 +15,7 @@ const BundleAnalyzerPlugin =
15
15
16
16
const Build = require ( '@jupyterlab/builder' ) . Build ;
17
17
const WPPlugin = require ( '@jupyterlab/builder' ) . WPPlugin ;
18
+ const HtmlWebpackPlugin = require ( 'html-webpack-plugin' ) ;
18
19
const baseConfig = require ( '@jupyterlab/builder/lib/webpack.config.base' ) ;
19
20
20
21
const data = require ( './package.json' ) ;
@@ -204,22 +205,55 @@ if (process.argv.includes('--analyze')) {
204
205
extras . push ( new BundleAnalyzerPlugin ( ) ) ;
205
206
}
206
207
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
+
207
228
module . exports = [
208
229
merge ( baseConfig , {
209
230
mode : 'development' ,
210
231
entry : [ './publicpath.js' , './' + path . relative ( __dirname , entryPoint ) ] ,
211
232
output : {
212
233
path : path . resolve ( __dirname , '..' , 'notebook/static/' ) ,
234
+ publicPath : '{{page_config.fullStaticUrl}}/' ,
213
235
library : {
214
236
type : 'var' ,
215
237
name : [ '_JUPYTERLAB' , 'CORE_OUTPUT' ] ,
216
238
} ,
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
+ } ,
218
251
} ,
219
252
resolve : {
220
253
fallback : { util : false } ,
221
254
} ,
222
255
plugins : [
256
+ ...htmlPlugins ,
223
257
new WPPlugin . JSONLicenseWebpackPlugin ( {
224
258
excludedPackageTest : ( packageName ) =>
225
259
packageName === '@jupyter-notebook/app' ,
@@ -235,3 +269,6 @@ module.exports = [
235
269
] ,
236
270
} ) ,
237
271
] . concat ( extras ) ;
272
+
273
+ const logPath = path . join ( buildDir , 'build_log.json' ) ;
274
+ fs . writeFileSync ( logPath , JSON . stringify ( module . exports , null , ' ' ) ) ;
0 commit comments