Просмотр исходного кода

fix(compiler-sfc): `less` and `stylus` output deps path is absolute p… (#1685)

underfin 5 лет назад
Родитель
Сommit
578f25c34e
1 измененных файлов с 2 добавлено и 16 удалено
  1. 2 16
      packages/compiler-sfc/src/stylePreprocessors.ts

+ 2 - 16
packages/compiler-sfc/src/stylePreprocessors.ts

@@ -1,5 +1,4 @@
 import merge from 'merge-source-map'
 import merge from 'merge-source-map'
-import path from 'path'
 import { RawSourceMap } from 'source-map'
 import { RawSourceMap } from 'source-map'
 import { SFCStyleCompileOptions } from './compileStyle'
 import { SFCStyleCompileOptions } from './compileStyle'
 
 
@@ -33,7 +32,6 @@ const scss: StylePreprocessor = (source, map, options, load = require) => {
 
 
   try {
   try {
     const result = nodeSass.renderSync(finalOptions)
     const result = nodeSass.renderSync(finalOptions)
-    // sass output path is position path
     const dependencies = result.stats.includedFiles
     const dependencies = result.stats.includedFiles
     if (map) {
     if (map) {
       return {
       return {
@@ -77,11 +75,7 @@ const less: StylePreprocessor = (source, map, options, load = require) => {
   )
   )
 
 
   if (error) return { code: '', errors: [error], dependencies: [] }
   if (error) return { code: '', errors: [error], dependencies: [] }
-  // less output path is relative path
-  const dependencies = getAbsolutePaths(
-    result.imports,
-    path.dirname(options.filename)
-  )
+  const dependencies = result.imports
   if (map) {
   if (map) {
     return {
     return {
       code: result.css.toString(),
       code: result.css.toString(),
@@ -107,11 +101,7 @@ const styl: StylePreprocessor = (source, map, options, load = require) => {
     if (map) ref.set('sourcemap', { inline: false, comment: false })
     if (map) ref.set('sourcemap', { inline: false, comment: false })
 
 
     const result = ref.render()
     const result = ref.render()
-    // stylus output path is relative path
-    const dependencies = getAbsolutePaths(
-      ref.deps(),
-      path.dirname(options.filename)
-    )
+    const dependencies = ref.deps()
     if (map) {
     if (map) {
       return {
       return {
         code: result,
         code: result,
@@ -136,7 +126,3 @@ export const processors: Record<PreprocessLang, StylePreprocessor> = {
   styl,
   styl,
   stylus: styl
   stylus: styl
 }
 }
-
-function getAbsolutePaths(relativePaths: string[], dirname: string): string[] {
-  return relativePaths.map(relativePath => path.join(dirname, relativePath))
-}