Skip to content

Commit

Permalink
fix(next-plugin): url statements in vanilla css would not respect nex…
Browse files Browse the repository at this point in the history
…t's setup for resolving assets (#1155)
  • Loading branch information
GeeWizWow committed Aug 9, 2023
1 parent 40d7e72 commit 1cb537b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-starfishes-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vanilla-extract/next-plugin': patch
---

Fix URL statements not not respecting Next's setup for resolving assets
13 changes: 13 additions & 0 deletions packages/next-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { VanillaExtractPlugin } from '@vanilla-extract/webpack-plugin';
import browserslist from 'browserslist';
import { lazyPostCSS } from 'next/dist/build/webpack/config/blocks/css';
import { findPagesDir } from 'next/dist/lib/find-pages-dir';
import { cssFileResolve } from 'next/dist/build/webpack/config/blocks/css/loaders/file-resolve';
import NextMiniCssExtractPluginDefault from 'next/dist/build/webpack/plugins/mini-css-extract-plugin';

import type webpack from 'webpack';
Expand Down Expand Up @@ -60,6 +61,18 @@ const getVanillaExtractCssLoaders = (
postcss,
importLoaders: 1,
modules: false,
url: (url: string, resourcePath: string) =>
cssFileResolve(
url,
resourcePath,
options.config.experimental?.urlImports,
),
import: (url: string, _: any, resourcePath: string) =>
cssFileResolve(
url,
resourcePath,
options.config.experimental?.urlImports,
),
},
});

Expand Down

0 comments on commit 1cb537b

Please sign in to comment.