Skip to content

Commit

Permalink
fix(stylus): make sure imported files with preprocessor imports optio…
Browse files Browse the repository at this point in the history
…n are watched as deps
  • Loading branch information
qnp committed Apr 8, 2021
1 parent 8949333 commit 311a0aa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,9 @@ const styl: StylePreprocessor = async (source, root, options) => {
// Get source with preprocessor options.additionalData. Make sure a new line separator
// is added to avoid any render error, as added stylus content may not have semi-colon separators
source = await getSource(source, options.filename, options.additionalData, '\n')
// Get preprocessor options.imports dependencies as stylus
// does not return them with its builtin `.deps()` method
const importsDeps = (options.imports || []).map((dep: string) => path.resolve(dep))
try {
const ref = nodeStylus(source, options)

Expand All @@ -1117,7 +1120,8 @@ const styl: StylePreprocessor = async (source, root, options) => {
const result = ref.render()

// @ts-expect-error: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/51919
const deps = ref.deps()
// Concat imports deps with computed deps
const deps = [...ref.deps(), ...importsDeps]

return { code: result, errors: [], deps }
} catch (e) {
Expand Down

0 comments on commit 311a0aa

Please sign in to comment.