File tree 4 files changed +129
-0
lines changed
4 files changed +129
-0
lines changed Original file line number Diff line number Diff line change 278
278
"noInfo" : {
279
279
"type" : " boolean"
280
280
},
281
+ "mimeTypes" : {
282
+ "type" : " object"
283
+ },
281
284
"quiet" : {
282
285
"type" : " boolean"
283
286
},
342
345
"reporter" : " should be {Function} (https://webpack.js.org/configuration/dev-server/#devserver-reporter)" ,
343
346
"logTime" : " should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-logtime)" ,
344
347
"noInfo" : " should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-noinfo-)" ,
348
+ "mimeTypes" : " should be {Object} (https://webpack.js.org/configuration/dev-server/#devservermimetypes-)" ,
345
349
"quiet" : " should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-quiet-)" ,
346
350
"serverSideRender" : " should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserver-serversiderender)" ,
347
351
"index" : " should be {String} (https://webpack.js.org/configuration/dev-server/#devserver-index)" ,
Original file line number Diff line number Diff line change @@ -516,6 +516,32 @@ describe('createConfig', () => {
516
516
expect ( config ) . toMatchSnapshot ( ) ;
517
517
} ) ;
518
518
519
+ it ( 'mimeTypes option' , ( ) => {
520
+ const config = createConfig (
521
+ Object . assign ( { } , webpackConfig , {
522
+ devServer : { mimeTypes : { 'text/html' : [ 'phtml' ] } } ,
523
+ } ) ,
524
+ argv ,
525
+ { port : 8080 }
526
+ ) ;
527
+
528
+ expect ( config ) . toMatchSnapshot ( ) ;
529
+ } ) ;
530
+
531
+ it ( 'mimeTypes option - with force' , ( ) => {
532
+ const config = createConfig (
533
+ Object . assign ( { } , webpackConfig , {
534
+ devServer : {
535
+ mimeTypes : { typeMap : { 'text/html' : [ 'phtml' ] } , force : true } ,
536
+ } ,
537
+ } ) ,
538
+ argv ,
539
+ { port : 8080 }
540
+ ) ;
541
+
542
+ expect ( config ) . toMatchSnapshot ( ) ;
543
+ } ) ;
544
+
519
545
it ( 'quiet option' , ( ) => {
520
546
const config = createConfig (
521
547
webpackConfig ,
Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const request = require ( 'supertest' ) ;
4
+ const helper = require ( './helper' ) ;
5
+ const config = require ( './fixtures/simple-config/webpack.config' ) ;
6
+
7
+ describe ( 'MimeTypes configuration' , ( ) => {
8
+ afterEach ( helper . close ) ;
9
+
10
+ it ( 'remapping mime type without force should throw an error' , ( ) => {
11
+ expect ( ( ) => {
12
+ helper . start ( config , {
13
+ mimeTypes : { 'application/octet-stream' : [ 'js' ] } ,
14
+ } ) ;
15
+ } ) . toThrow ( / A t t e m p t t o c h a n g e m a p p i n g f o r / ) ;
16
+ } ) ;
17
+
18
+ it ( 'remapping mime type with force should not throw an error' , ( done ) => {
19
+ helper . start (
20
+ config ,
21
+ {
22
+ mimeTypes : {
23
+ typeMap : { 'application/octet-stream' : [ 'js' ] } ,
24
+ force : true ,
25
+ } ,
26
+ } ,
27
+ done
28
+ ) ;
29
+ } ) ;
30
+ } ) ;
31
+
32
+ describe ( 'custom mimeTypes' , ( ) => {
33
+ let server ;
34
+ let req ;
35
+
36
+ beforeAll ( ( done ) => {
37
+ server = helper . start (
38
+ config ,
39
+ {
40
+ mimeTypes : {
41
+ typeMap : { 'application/octet-stream' : [ 'js' ] } ,
42
+ force : true ,
43
+ } ,
44
+ } ,
45
+ done
46
+ ) ;
47
+ req = request ( server . app ) ;
48
+ } ) ;
49
+
50
+ afterAll ( helper . close ) ;
51
+
52
+ it ( 'request to bundle file with modified mime type' , ( done ) => {
53
+ req
54
+ . get ( '/main.js' )
55
+ . expect ( 'Content-Type' , / a p p l i c a t i o n \/ o c t e t - s t r e a m / )
56
+ . expect ( 200 , done ) ;
57
+ } ) ;
58
+ } ) ;
Original file line number Diff line number Diff line change @@ -671,6 +671,47 @@ Object {
671
671
}
672
672
` ;
673
673
674
+ exports [` createConfig mimeTypes option - with force 1` ] = `
675
+ Object {
676
+ " hot" : true ,
677
+ " hotOnly" : false ,
678
+ " mimeTypes" : Object {
679
+ " force" : true ,
680
+ " typeMap" : Object {
681
+ " text/html" : Array [
682
+ " phtml" ,
683
+ ],
684
+ },
685
+ },
686
+ " noInfo" : true ,
687
+ " port" : 8080 ,
688
+ " publicPath" : " /" ,
689
+ " stats" : Object {
690
+ " cached" : false ,
691
+ " cachedAssets" : false ,
692
+ },
693
+ }
694
+ ` ;
695
+
696
+ exports [` createConfig mimeTypes option 1` ] = `
697
+ Object {
698
+ " hot" : true ,
699
+ " hotOnly" : false ,
700
+ " mimeTypes" : Object {
701
+ " text/html" : Array [
702
+ " phtml" ,
703
+ ],
704
+ },
705
+ " noInfo" : true ,
706
+ " port" : 8080 ,
707
+ " publicPath" : " /" ,
708
+ " stats" : Object {
709
+ " cached" : false ,
710
+ " cachedAssets" : false ,
711
+ },
712
+ }
713
+ ` ;
714
+
674
715
exports [` createConfig open option (boolean) (in devServer config) 1` ] = `
675
716
Object {
676
717
" hot" : true ,
You can’t perform that action at this time.
0 commit comments