]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(compiler-sfc): `less` and `stylus` output deps path is absolute p… (#1685)
authorunderfin <2218301630@qq.com>
Tue, 28 Jul 2020 17:45:24 +0000 (01:45 +0800)
committerGitHub <noreply@github.com>
Tue, 28 Jul 2020 17:45:24 +0000 (13:45 -0400)
packages/compiler-sfc/src/stylePreprocessors.ts

index 2aa459a17817fbb5e0aef3ee4579b5c850a15fc0..a50c30d1c6ab4c3fbec10a5a92860ab59e7b4d62 100644 (file)
@@ -1,5 +1,4 @@
 import merge from 'merge-source-map'
-import path from 'path'
 import { RawSourceMap } from 'source-map'
 import { SFCStyleCompileOptions } from './compileStyle'
 
@@ -33,7 +32,6 @@ const scss: StylePreprocessor = (source, map, options, load = require) => {
 
   try {
     const result = nodeSass.renderSync(finalOptions)
-    // sass output path is position path
     const dependencies = result.stats.includedFiles
     if (map) {
       return {
@@ -77,11 +75,7 @@ const less: StylePreprocessor = (source, map, options, load = require) => {
   )
 
   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) {
     return {
       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 })
 
     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) {
       return {
         code: result,
@@ -136,7 +126,3 @@ export const processors: Record<PreprocessLang, StylePreprocessor> = {
   styl,
   stylus: styl
 }
-
-function getAbsolutePaths(relativePaths: string[], dirname: string): string[] {
-  return relativePaths.map(relativePath => path.join(dirname, relativePath))
-}