Closed GeeWizWow closed 1 year ago
Providing a patch for anyone running into this issue, can be used with patch-package
patches/@vanilla-extract+next-plugin+2.2.1.patch
with the content belownpm install --save-dev patch-package
"scripts": {
+ "postinstall": "patch-package"
}
diff --git a/node_modules/@vanilla-extract/next-plugin/dist/vanilla-extract-next-plugin.cjs.dev.js b/node_modules/@vanilla-extract/next-plugin/dist/vanilla-extract-next-plugin.cjs.dev.js
index fc2b24b..4d11d27 100644
--- a/node_modules/@vanilla-extract/next-plugin/dist/vanilla-extract-next-plugin.cjs.dev.js
+++ b/node_modules/@vanilla-extract/next-plugin/dist/vanilla-extract-next-plugin.cjs.dev.js
@@ -7,6 +7,7 @@ var browserslist = require('browserslist');
var css = require('next/dist/build/webpack/config/blocks/css');
var findPagesDir = require('next/dist/lib/find-pages-dir');
var NextMiniCssExtractPluginDefault = require('next/dist/build/webpack/plugins/mini-css-extract-plugin');
+var nextFileResolve = require('next/dist/build/webpack/config/blocks/css/loaders/file-resolve');
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -50,7 +51,9 @@ const getVanillaExtractCssLoaders = (options, assetPrefix) => {
options: {
postcss,
importLoaders: 1,
- modules: false
+ modules: false,
+ url: (url, resourcePath) => nextFileResolve.cssFileResolve(url, resourcePath, options.config.experimental.urlImports),
+ import: (url, _, resourcePath) => nextFileResolve.cssFileResolve(url, resourcePath, options.config.experimental.urlImports),
}
});
diff --git a/node_modules/@vanilla-extract/next-plugin/dist/vanilla-extract-next-plugin.cjs.prod.js b/node_modules/@vanilla-extract/next-plugin/dist/vanilla-extract-next-plugin.cjs.prod.js
index fc2b24b..4d11d27 100644
--- a/node_modules/@vanilla-extract/next-plugin/dist/vanilla-extract-next-plugin.cjs.prod.js
+++ b/node_modules/@vanilla-extract/next-plugin/dist/vanilla-extract-next-plugin.cjs.prod.js
@@ -7,6 +7,7 @@ var browserslist = require('browserslist');
var css = require('next/dist/build/webpack/config/blocks/css');
var findPagesDir = require('next/dist/lib/find-pages-dir');
var NextMiniCssExtractPluginDefault = require('next/dist/build/webpack/plugins/mini-css-extract-plugin');
+var nextFileResolve = require('next/dist/build/webpack/config/blocks/css/loaders/file-resolve');
function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -50,7 +51,9 @@ const getVanillaExtractCssLoaders = (options, assetPrefix) => {
options: {
postcss,
importLoaders: 1,
- modules: false
+ modules: false,
+ url: (url, resourcePath) => nextFileResolve.cssFileResolve(url, resourcePath, options.config.experimental.urlImports),
+ import: (url, _, resourcePath) => nextFileResolve.cssFileResolve(url, resourcePath, options.config.experimental.urlImports),
}
});
Describe the bug
Using the newer
@vanilla-extract/next-plugin
versions 2.2.0 or 2.2.1, it appears that the css-loader loader used by vanilla extract:https://github.com/vanilla-extract-css/vanilla-extract/blob/40d7e72c041989a4dc847dc66b94a4c680b5536e/packages/next-plugin/src/index.ts#L58
no longer respects/ uses the url option setup by next, which is defined here:
This leads to the following css failing to build with a failed to resolve module error:
likewise for anything that uses url, such as fontFace:
Reproduction
https://codesandbox.io/p/sandbox/withered-bush-5yt993
System Info
Used Package Manager
npm
Logs
Validations