File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22 MIT License http://www.opensource.org/licenses/mit-license.php
33 Author Tobias Koppers @sokra
44*/
5- function NodeSourceRealPathsPlugin ( ) {
5+ var path = require ( "path" ) ;
6+
7+ function NodeSourceRealPathsPlugin ( context ) {
8+ this . context = context ;
69}
710module . exports = NodeSourceRealPathsPlugin ;
811NodeSourceRealPathsPlugin . prototype . apply = function ( compiler ) {
12+ var context = this . context ;
913 compiler . parser . plugin ( "expression __filename" , function ( expr ) {
1014 if ( ! this . state . module ) return false ;
11- this . state . current . addVariable ( "__filename" , JSON . stringify ( this . state . module . resource ) ) ;
15+ this . state . current . addVariable ( "__filename" , JSON . stringify (
16+ context ? path . relative ( context , this . state . module . resource ) : this . state . module . resource
17+ ) ) ;
1218 return true ;
1319 } ) ;
1420 compiler . parser . plugin ( "expression __dirname" , function ( expr ) {
1521 if ( ! this . state . module ) return false ;
16- this . state . current . addVariable ( "__dirname" , JSON . stringify ( this . state . module . context ) ) ;
22+ this . state . current . addVariable ( "__dirname" , JSON . stringify (
23+ context ? path . relative ( context , this . state . module . context ) : this . state . module . context
24+ ) ) ;
1725 return true ;
1826 } ) ;
1927} ;
You can’t perform that action at this time.
0 commit comments