Skip to content

Commit

Permalink
fix(compiler-sfc): less and stylus output deps path is absolute p… (
Browse files Browse the repository at this point in the history
  • Loading branch information
underfin authored Jul 28, 2020
1 parent 4ef5c8d commit 578f25c
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions packages/compiler-sfc/src/stylePreprocessors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import merge from 'merge-source-map'
import path from 'path'
import { RawSourceMap } from 'source-map'
import { SFCStyleCompileOptions } from './compileStyle'

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
Expand All @@ -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))
}

0 comments on commit 578f25c

Please sign in to comment.