Skip to content

Commit

Permalink
accept css files outside of the project as virtual assets (vercel/tur…
Browse files Browse the repository at this point in the history
…borepo#7719)

### Description

This can actually happen e. g. with next/font, which creates virtual css
files that are not inside of the project directory

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->


Closes PACK-2732
  • Loading branch information
sokra authored Mar 13, 2024
1 parent fb3d3cd commit 682eaa1
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions crates/turbopack-node/src/transforms/postcss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ use indexmap::indexmap;
use indoc::formatdoc;
use serde::{Deserialize, Serialize};
use turbo_tasks::{
trace::TraceRawVcs, Completion, Completions, TaskInput, TryFlatJoinIterExt, Value,
ValueToString, Vc,
trace::TraceRawVcs, Completion, Completions, TaskInput, TryFlatJoinIterExt, Value, Vc,
};
use turbo_tasks_bytes::stream::SingleValue;
use turbo_tasks_fs::{
Expand Down Expand Up @@ -375,15 +374,14 @@ impl PostCssTransformedAsset {

// We need to get a path relative to the project because the postcss loader
// runs with the project as the current working directory.
let Some(css_path) = project_path
let css_path = if let Some(css_path) = project_path
.await?
.get_relative_path_to(&*css_fs_path.await?)
else {
bail!(
"CSS path {} is outside of the project {}",
css_fs_path.to_string().await?,
project_path.to_string().await?
);
{
css_path
} else {
// This shouldn't be an error since it can happen on virtual assets
"".to_string()
};

let config_value = evaluate_webpack_loader(WebpackLoaderContext {
Expand Down

0 comments on commit 682eaa1

Please sign in to comment.