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 Mar 26, 2021
1 parent eb66b43 commit dcb7ef7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vite/src/node/plugins/css.ts
Expand Up @@ -553,7 +553,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 @@ -846,7 +846,7 @@ type PreprocessorAdditionalData =

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

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

function loadPreprocessor(lang: PreprocessLang, root: string) {
function loadPreprocessor(lang: PreprocessLang, root: string[]) {
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 dcb7ef7

Please sign in to comment.