File tree Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Expand file tree Collapse file tree 1 file changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -23,21 +23,18 @@ var CreateFilePlugin = (function () {
23
23
this . options = options ;
24
24
}
25
25
26
- function _createFile ( filePath , fileName , content ) {
27
- return ( ) => {
28
- const fullPath = path . join ( filePath , fileName ) ;
29
- write . sync ( fullPath , content ) ;
30
- }
31
- }
32
-
33
26
CreateFilePlugin . prototype . apply = function ( compiler ) {
34
- const createFile = ( ) => _createFile ( this . options . path , this . options . fileName , this . options . content ) ;
27
+ compiler . hooks . emit . tap ( { name : 'CreateFileWebpack' } , compilation => {
28
+ const relativePath = path . join ( this . options . path , this . options . fileName ) ;
29
+ const targetPath = path . join ( compiler . options . output . path , relativePath ) ;
35
30
36
- if ( ! ! compiler . hooks ) {
37
- compiler . hooks . done . tap ( 'CreateFileWebpack' , createFile ( ) ) ;
38
- } else {
39
- compiler . plugin ( 'done' , createFile ( ) ) ;
40
- }
31
+ write . sync ( targetPath , this . options . content ) ;
32
+
33
+ compilation . assets [ relativePath ] = {
34
+ source : ( ) => this . options . content ,
35
+ size : ( ) => this . options . content . length
36
+ } ;
37
+ } ) ;
41
38
} ;
42
39
43
40
return CreateFilePlugin ;
You can’t perform that action at this time.
0 commit comments