@@ -462,106 +462,106 @@ describe('filtering unwanted files', function() {
462462} ) ;
463463
464464describe ( 'multiple html' , function ( ) {
465- // it('each one only include their own chunk', function(done) {
466- // const compiler = webpack({
467- // entry: {
468- // js: path.join(__dirname, 'fixtures', 'file.js'),
469- // moduleA: path.join(__dirname, 'fixtures', 'module-a.js')
470- // },
471- // output: {
472- // path: OUTPUT_DIR,
473- // filename: '[name].js',
474- // chunkFilename: 'chunk.[chunkhash].js',
475- // publicPath: '/',
476- // },
477- // devtool: 'cheap-source-map',
478- // plugins: [
479- // new HtmlWebpackPlugin({
480- // filename: 'index.html',
481- // chunks: ['js'],
482- // }),
483- // new HtmlWebpackPlugin({
484- // filename: 'home.html',
485- // chunks: ['moduleA'],
486- // }),
487- // new PreloadPlugin()
488- // ]
489- // }, function(err, result) {
490- // expect(err).toBeFalsy();
491- // expect(JSON.stringify(result.compilation.errors)).toBe('[]');
492- // const html = result.compilation.assets['index.html'].source();
493- // const homeHtml = result.compilation.assets['home.html'].source();
494- // expect(html).toContain('<link rel="preload" as="script" href="/chunk.');
495- // expect(homeHtml).not.toContain('<link rel="preload" as="script" href="/chunk.');
496- // done();
497- // });
498- // compiler.outputFileSystem = new MemoryFileSystem();
499- // });
465+ it ( 'each one only include their own chunk' , function ( done ) {
466+ const compiler = webpack ( {
467+ entry : {
468+ js : path . join ( __dirname , 'fixtures' , 'file.js' ) ,
469+ moduleA : path . join ( __dirname , 'fixtures' , 'module-a.js' )
470+ } ,
471+ output : {
472+ path : OUTPUT_DIR ,
473+ filename : '[name].js' ,
474+ chunkFilename : 'chunk.[chunkhash].js' ,
475+ publicPath : '/' ,
476+ } ,
477+ devtool : 'cheap-source-map' ,
478+ plugins : [
479+ new HtmlWebpackPlugin ( {
480+ filename : 'index.html' ,
481+ chunks : [ 'js' ] ,
482+ } ) ,
483+ new HtmlWebpackPlugin ( {
484+ filename : 'home.html' ,
485+ chunks : [ 'moduleA' ] ,
486+ } ) ,
487+ new PreloadPlugin ( )
488+ ]
489+ } , function ( err , result ) {
490+ expect ( err ) . toBeFalsy ( ) ;
491+ expect ( JSON . stringify ( result . compilation . errors ) ) . toBe ( '[]' ) ;
492+ const html = result . compilation . assets [ 'index.html' ] . source ( ) ;
493+ const homeHtml = result . compilation . assets [ 'home.html' ] . source ( ) ;
494+ expect ( html ) . toContain ( '<link rel="preload" as="script" href="/chunk.' ) ;
495+ expect ( homeHtml ) . not . toContain ( '<link rel="preload" as="script" href="/chunk.' ) ;
496+ done ( ) ;
497+ } ) ;
498+ compiler . outputFileSystem = new MemoryFileSystem ( ) ;
499+ } ) ;
500500
501- // it('exclude by html filename', function(done) {
502- // const compiler = webpack({
503- // entry: {
504- // js: path.join(__dirname, 'fixtures', 'file.js')
505- // },
506- // output: {
507- // path: OUTPUT_DIR,
508- // filename: '[name].js',
509- // chunkFilename: 'chunk.[chunkhash].js',
510- // publicPath: '/',
511- // },
512- // devtool: 'cheap-source-map',
513- // plugins: [
514- // new HtmlWebpackPlugin({
515- // filename: 'index.html',
516- // chunks: ['js'],
517- // }),
518- // new HtmlWebpackPlugin({
519- // filename: 'home.html',
520- // chunks: ['js'],
521- // }),
522- // new PreloadPlugin({
523- // excludeHtmlNames: ['index.html'],
524- // })
525- // ]
526- // }, function(err, result) {
527- // expect(err).toBeFalsy();
528- // expect(JSON.stringify(result.compilation.errors)).toBe('[]');
529- // const html = result.compilation.assets['index.html'].source();
530- // const homeHtml = result.compilation.assets['home.html'].source();
531- // expect(html).not.toContain('<link rel="preload" as="script" href="/chunk.');
532- // expect(homeHtml).toContain('<link rel="preload" as="script" href="/chunk.');
533- // done();
534- // });
535- // compiler.outputFileSystem = new MemoryFileSystem();
536- // });
537- // });
501+ it ( 'exclude by html filename' , function ( done ) {
502+ const compiler = webpack ( {
503+ entry : {
504+ js : path . join ( __dirname , 'fixtures' , 'file.js' )
505+ } ,
506+ output : {
507+ path : OUTPUT_DIR ,
508+ filename : '[name].js' ,
509+ chunkFilename : 'chunk.[chunkhash].js' ,
510+ publicPath : '/' ,
511+ } ,
512+ devtool : 'cheap-source-map' ,
513+ plugins : [
514+ new HtmlWebpackPlugin ( {
515+ filename : 'index.html' ,
516+ chunks : [ 'js' ] ,
517+ } ) ,
518+ new HtmlWebpackPlugin ( {
519+ filename : 'home.html' ,
520+ chunks : [ 'js' ] ,
521+ } ) ,
522+ new PreloadPlugin ( {
523+ excludeHtmlNames : [ 'index.html' ] ,
524+ } )
525+ ]
526+ } , function ( err , result ) {
527+ expect ( err ) . toBeFalsy ( ) ;
528+ expect ( JSON . stringify ( result . compilation . errors ) ) . toBe ( '[]' ) ;
529+ const html = result . compilation . assets [ 'index.html' ] . source ( ) ;
530+ const homeHtml = result . compilation . assets [ 'home.html' ] . source ( ) ;
531+ expect ( html ) . not . toContain ( '<link rel="preload" as="script" href="/chunk.' ) ;
532+ expect ( homeHtml ) . toContain ( '<link rel="preload" as="script" href="/chunk.' ) ;
533+ done ( ) ;
534+ } ) ;
535+ compiler . outputFileSystem = new MemoryFileSystem ( ) ;
536+ } ) ;
537+ } ) ;
538538
539- // describe('filtering unwanted html', function() {
540- // it('does not include preload asset into index.html file', function(done) {
541- // const compiler = webpack({
542- // entry: {
543- // js: path.join(__dirname, 'fixtures', 'file.js')
544- // },
545- // output: {
546- // path: OUTPUT_DIR,
547- // filename: 'bundle.js',
548- // chunkFilename: 'chunk.[chunkhash].js',
549- // publicPath: '/',
550- // },
551- // devtool: 'cheap-source-map',
552- // plugins: [
553- // new HtmlWebpackPlugin(),
554- // new PreloadPlugin({
555- // excludeHtmlNames: ['index.html'],
556- // })
557- // ]
558- // }, function(err, result) {
559- // expect(err).toBeFalsy();
560- // expect(JSON.stringify(result.compilation.errors)).toBe('[]');
561- // const html = result.compilation.assets['index.html'].source();
562- // expect(html).not.toContain('<link rel="preload" as="script" href="/chunk.');
563- // done();
564- // });
565- // compiler.outputFileSystem = new MemoryFileSystem();
566- // });
539+ describe ( 'filtering unwanted html' , function ( ) {
540+ it ( 'does not include preload asset into index.html file' , function ( done ) {
541+ const compiler = webpack ( {
542+ entry : {
543+ js : path . join ( __dirname , 'fixtures' , 'file.js' )
544+ } ,
545+ output : {
546+ path : OUTPUT_DIR ,
547+ filename : 'bundle.js' ,
548+ chunkFilename : 'chunk.[chunkhash].js' ,
549+ publicPath : '/' ,
550+ } ,
551+ devtool : 'cheap-source-map' ,
552+ plugins : [
553+ new HtmlWebpackPlugin ( ) ,
554+ new PreloadPlugin ( {
555+ excludeHtmlNames : [ 'index.html' ] ,
556+ } )
557+ ]
558+ } , function ( err , result ) {
559+ expect ( err ) . toBeFalsy ( ) ;
560+ expect ( JSON . stringify ( result . compilation . errors ) ) . toBe ( '[]' ) ;
561+ const html = result . compilation . assets [ 'index.html' ] . source ( ) ;
562+ expect ( html ) . not . toContain ( '<link rel="preload" as="script" href="/chunk.' ) ;
563+ done ( ) ;
564+ } ) ;
565+ compiler . outputFileSystem = new MemoryFileSystem ( ) ;
566+ } ) ;
567567} ) ;
0 commit comments