@@ -31,7 +31,8 @@ function generateShortName (name, filename, css) {
31
31
Appends a hash of the css source.
32
32
*/
33
33
function generateLongName ( name , filename ) {
34
- var sanitisedPath = filename . replace ( / \. [ ^ \. \/ \\ ] + $ / , '' )
34
+ var relativePath = path . relative ( rootDir , filename )
35
+ var sanitisedPath = relativePath . replace ( / \. [ ^ \. \/ \\ ] + $ / , '' )
35
36
. replace ( / [ \W _ ] + / g, '_' )
36
37
. replace ( / ^ _ | _ $ / g, '' ) ;
37
38
d ( '@@@@sanitiedPath' , sanitisedPath , filename )
@@ -67,12 +68,13 @@ var tokensByEntrypoint = {};
67
68
68
69
// we need a separate loader for each entry point
69
70
var bundledCss = ''
71
+ var rootDir
70
72
71
73
module . exports = function ( browserify , options ) {
72
74
options = options || { } ;
73
75
74
76
// if no root directory is specified, assume the cwd
75
- var rootDir = options . rootDir || options . d || browserify . _options . basedir ;
77
+ rootDir = options . rootDir || options . d || browserify . _options . basedir ;
76
78
if ( rootDir ) { rootDir = path . resolve ( rootDir ) ; }
77
79
if ( ! rootDir ) { rootDir = process . cwd ( ) ; }
78
80
@@ -104,12 +106,12 @@ module.exports = function (browserify, options) {
104
106
105
107
postcss ( modules ( {
106
108
generateScopedName : generateLongName ,
107
- getJSON : ( cssFilename , css ) => {
108
- d ( '======getJSON========' , cssFilename )
109
- self . push ( 'module.exports = ' + JSON . stringify ( css ) )
109
+ getJSON : ( cssFilename , json ) => {
110
+ d ( '======getJSON========' , cssFilename , json )
111
+ self . push ( 'module.exports = ' + JSON . stringify ( json ) )
110
112
} ,
111
113
} ) )
112
- . process ( this . _data , { from : '/' + relFilename } )
114
+ . process ( this . _data , { from : relFilename } )
113
115
. then ( ( result ) => {
114
116
d ( '=========result=======' ) ;
115
117
d ( result . css ) ;
0 commit comments