@@ -39,7 +39,7 @@ export default (patterns = [], options = {}) => {
3939 }
4040
4141 const apply = ( compiler ) => {
42- const baseDir = compiler . options . context ;
42+ const webpackContext = compiler . options . context ;
4343 const outputPath = getOutputDir ( compiler ) ;
4444 const fileDependencies = [ ] ;
4545 const contextDependencies = [ ] ;
@@ -56,9 +56,16 @@ export default (patterns = [], options = {}) => {
5656 Promise . each ( patterns , ( pattern ) => {
5757 let relDest ;
5858 let globOpts ;
59+ let context ;
60+
61+ if ( pattern . context && ! path . isAbsolute ( pattern . context ) ) {
62+ pattern . context = path . resolve ( webpackContext , pattern . context ) ;
63+ }
64+
65+ context = pattern . context || webpackContext ;
5966
6067 globOpts = {
61- cwd : baseDir
68+ cwd : context
6269 } ;
6370
6471 // From can be an object
@@ -68,7 +75,7 @@ export default (patterns = [], options = {}) => {
6875 }
6976
7077 const relSrc = pattern . from ;
71- const absSrc = path . resolve ( baseDir , relSrc ) ;
78+ const absSrc = path . resolve ( context , relSrc ) ;
7279
7380 relDest = pattern . to || '' ;
7481
@@ -111,7 +118,7 @@ export default (patterns = [], options = {}) => {
111118 return false ;
112119 }
113120
114- const absFileSrc = path . resolve ( baseDir , relFileSrc ) ;
121+ const absFileSrc = path . resolve ( context , relFileSrc ) ;
115122
116123 relFileDest = pattern . to || '' ;
117124
@@ -124,7 +131,7 @@ export default (patterns = [], options = {}) => {
124131 // If the source is absolute
125132 if ( path . isAbsolute ( relFileSrc ) ) {
126133 // Make the destination relative
127- relFileDest = path . join ( path . relative ( baseDir , relFileDirname ) , path . basename ( relFileSrc ) ) ;
134+ relFileDest = path . join ( path . relative ( context , relFileDirname ) , path . basename ( relFileSrc ) ) ;
128135
129136 // If the source is relative
130137 } else {
0 commit comments