Browse Source

fix(compiler-sfc): fix preprocessor filename access

Evan You 6 years ago
parent
commit
9cb29eea3a
1 changed files with 9 additions and 4 deletions
  1. 9 4
      packages/compiler-sfc/src/stylePreprocessors.ts

+ 9 - 4
packages/compiler-sfc/src/stylePreprocessors.ts

@@ -1,12 +1,17 @@
 import merge from 'merge-source-map'
 import merge from 'merge-source-map'
 import path from 'path'
 import path from 'path'
+import { RawSourceMap } from 'source-map'
+import { SFCStyleCompileOptions } from './compileStyle'
 
 
 export interface StylePreprocessor {
 export interface StylePreprocessor {
   render(
   render(
     source: string,
     source: string,
-    map?: object,
-    options?: any,
-    customRequire?: (id: string) => any
+    map: RawSourceMap | undefined,
+    options: {
+      [key: string]: any
+      filename: string
+    },
+    customRequire: SFCStyleCompileOptions['preprocessCustomRequire']
   ): StylePreprocessorResults
   ): StylePreprocessorResults
 }
 }
 
 
@@ -83,7 +88,7 @@ const less: StylePreprocessor = {
     // less output path is relative path
     // less output path is relative path
     const dependencies = getAbsolutePaths(
     const dependencies = getAbsolutePaths(
       result.imports,
       result.imports,
-      path.dirname(options.fileName)
+      path.dirname(options.filename)
     )
     )
     if (map) {
     if (map) {
       return {
       return {