From 578f25c34efab0a71a7afd8bff278bd147a16a64 Mon Sep 17 00:00:00 2001 From: underfin <2218301630@qq.com> Date: Wed, 29 Jul 2020 01:45:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(compiler-sfc):=20`less`=20and=20`stylus`=20?= =?UTF-8?q?output=20deps=20path=20is=20absolute=20p=E2=80=A6=20(#1685)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compiler-sfc/src/stylePreprocessors.ts | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/packages/compiler-sfc/src/stylePreprocessors.ts b/packages/compiler-sfc/src/stylePreprocessors.ts index 2aa459a17..a50c30d1c 100644 --- a/packages/compiler-sfc/src/stylePreprocessors.ts +++ b/packages/compiler-sfc/src/stylePreprocessors.ts @@ -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 = { styl, stylus: styl } - -function getAbsolutePaths(relativePaths: string[], dirname: string): string[] { - return relativePaths.map(relativePath => path.join(dirname, relativePath)) -}