Skip to content

Commit

Permalink
fix: loadPreprocessor from both configFile path and cwd
Browse files Browse the repository at this point in the history
  • Loading branch information
HomyeeKing committed Apr 9, 2021
1 parent ffcb7ce commit eeb9050
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ async function compileCSS(
opts.filename = cleanUrl(id)
const preprocessResult = await preProcessor(
code,
config.root,
[config.root, config.configFile || ''],
opts,
atImportResolvers
)
Expand Down Expand Up @@ -861,7 +861,7 @@ type PreprocessorAdditionalData =

type StylePreprocessor = (
source: string,
root: string,
root: string[],
options: {
[key: string]: any
additionalData?: PreprocessorAdditionalData
Expand All @@ -880,19 +880,19 @@ export interface StylePreprocessorResults {

const loadedPreprocessors: Partial<Record<PreprocessLang, any>> = {}

function loadPreprocessor(lang: PreprocessLang.scss, root: string): typeof Sass
function loadPreprocessor(lang: PreprocessLang.sass, root: string): typeof Sass
function loadPreprocessor(lang: PreprocessLang.less, root: string): typeof Less
function loadPreprocessor(lang: PreprocessLang.scss, root: string[]): typeof Sass
function loadPreprocessor(lang: PreprocessLang.sass, root: string[]): typeof Sass
function loadPreprocessor(lang: PreprocessLang.less, root: string[]): typeof Less
function loadPreprocessor(
lang: PreprocessLang.stylus,
root: string
root: string[]
): typeof Stylus
function loadPreprocessor(lang: PreprocessLang, root: string): any {
function loadPreprocessor(lang: PreprocessLang, root: string[]): any {
if (lang in loadedPreprocessors) {
return loadedPreprocessors[lang]
}
try {
const resolved = require.resolve(lang, { paths: [root] })
const resolved = require.resolve(lang, { paths: root })
return (loadedPreprocessors[lang] = require(resolved))
} catch (e) {
throw new Error(
Expand Down

0 comments on commit eeb9050

Please sign in to comment.