From dfc640593b5c627364c5423c3110b048f51844e4 Mon Sep 17 00:00:00 2001 From: mattcompiles Date: Thu, 29 Sep 2022 09:26:05 +1000 Subject: [PATCH] Don't output CSS on Next server builds (#852) --- .changeset/spicy-planes-approve.md | 7 +++++++ packages/next-plugin/src/index.js | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .changeset/spicy-planes-approve.md diff --git a/.changeset/spicy-planes-approve.md b/.changeset/spicy-planes-approve.md new file mode 100644 index 000000000..b47f38927 --- /dev/null +++ b/.changeset/spicy-planes-approve.md @@ -0,0 +1,7 @@ +--- +'@vanilla-extract/next-plugin': patch +--- + +Fix `Cannot find module *.css.ts.vanilla.css` issue + +Previously, CSS was being output on both the client and server builds. This fix ensure CSS is only output on the client build. \ No newline at end of file diff --git a/packages/next-plugin/src/index.js b/packages/next-plugin/src/index.js index 0bd3a6be4..e26488095 100644 --- a/packages/next-plugin/src/index.js +++ b/packages/next-plugin/src/index.js @@ -50,7 +50,9 @@ export const createVanillaExtractPlugin = ), }); - config.plugins.push(new VanillaExtractPlugin(pluginOptions)); + config.plugins.push( + new VanillaExtractPlugin({ outputCss: !isServer, ...pluginOptions }), + ); if (typeof nextConfig.webpack === 'function') { return nextConfig.webpack(config, options);