Skip to content

Commit 578f25c

Browse files
authored
fix(compiler-sfc): less and stylus output deps path is absolute p… (#1685)
1 parent 4ef5c8d commit 578f25c

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

packages/compiler-sfc/src/stylePreprocessors.ts

+2-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import merge from 'merge-source-map'
2-
import path from 'path'
32
import { RawSourceMap } from 'source-map'
43
import { SFCStyleCompileOptions } from './compileStyle'
54

@@ -33,7 +32,6 @@ const scss: StylePreprocessor = (source, map, options, load = require) => {
3332

3433
try {
3534
const result = nodeSass.renderSync(finalOptions)
36-
// sass output path is position path
3735
const dependencies = result.stats.includedFiles
3836
if (map) {
3937
return {
@@ -77,11 +75,7 @@ const less: StylePreprocessor = (source, map, options, load = require) => {
7775
)
7876

7977
if (error) return { code: '', errors: [error], dependencies: [] }
80-
// less output path is relative path
81-
const dependencies = getAbsolutePaths(
82-
result.imports,
83-
path.dirname(options.filename)
84-
)
78+
const dependencies = result.imports
8579
if (map) {
8680
return {
8781
code: result.css.toString(),
@@ -107,11 +101,7 @@ const styl: StylePreprocessor = (source, map, options, load = require) => {
107101
if (map) ref.set('sourcemap', { inline: false, comment: false })
108102

109103
const result = ref.render()
110-
// stylus output path is relative path
111-
const dependencies = getAbsolutePaths(
112-
ref.deps(),
113-
path.dirname(options.filename)
114-
)
104+
const dependencies = ref.deps()
115105
if (map) {
116106
return {
117107
code: result,
@@ -136,7 +126,3 @@ export const processors: Record<PreprocessLang, StylePreprocessor> = {
136126
styl,
137127
stylus: styl
138128
}
139-
140-
function getAbsolutePaths(relativePaths: string[], dirname: string): string[] {
141-
return relativePaths.map(relativePath => path.join(dirname, relativePath))
142-
}

0 commit comments

Comments
 (0)