@vanilla-extract/vite-plugin 3.7.1 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,8 +3,9 @@ import { IdentifierOption, CompileOptions } from '@vanilla-extract/integration';
|
|
|
3
3
|
|
|
4
4
|
interface Options {
|
|
5
5
|
identifiers?: IdentifierOption;
|
|
6
|
+
emitCssInSsr?: boolean;
|
|
6
7
|
esbuildOptions?: CompileOptions['esbuildOptions'];
|
|
7
8
|
}
|
|
8
|
-
declare function vanillaExtractPlugin({ identifiers, esbuildOptions, }?: Options): Plugin;
|
|
9
|
+
declare function vanillaExtractPlugin({ identifiers, emitCssInSsr, esbuildOptions, }?: Options): Plugin;
|
|
9
10
|
|
|
10
11
|
export { vanillaExtractPlugin };
|
|
@@ -69,13 +69,15 @@ const virtualExtCss = '.vanilla.css';
|
|
|
69
69
|
const virtualExtJs = '.vanilla.js';
|
|
70
70
|
function vanillaExtractPlugin({
|
|
71
71
|
identifiers,
|
|
72
|
+
emitCssInSsr,
|
|
72
73
|
esbuildOptions
|
|
73
74
|
} = {}) {
|
|
74
75
|
let config;
|
|
75
76
|
let server;
|
|
76
77
|
let postCssConfig;
|
|
77
78
|
const cssMap = new Map();
|
|
78
|
-
|
|
79
|
+
const hasEmitCssOverride = typeof emitCssInSsr === 'boolean';
|
|
80
|
+
let resolvedEmitCssInSsr = hasEmitCssOverride ? emitCssInSsr : !!process.env.VITE_RSC_BUILD;
|
|
79
81
|
let packageName;
|
|
80
82
|
const getAbsoluteVirtualFileId = source => vite.normalizePath(path__default["default"].join(config.root, source));
|
|
81
83
|
return {
|
|
@@ -101,8 +103,8 @@ function vanillaExtractPlugin({
|
|
|
101
103
|
if (config.command === 'serve') {
|
|
102
104
|
postCssConfig = await resolvePostcssConfig(config);
|
|
103
105
|
}
|
|
104
|
-
if (config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
105
|
-
|
|
106
|
+
if (!hasEmitCssOverride && config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
107
|
+
resolvedEmitCssInSsr = true;
|
|
106
108
|
}
|
|
107
109
|
},
|
|
108
110
|
resolveId(source) {
|
|
@@ -166,7 +168,7 @@ function vanillaExtractPlugin({
|
|
|
166
168
|
} else {
|
|
167
169
|
ssr = ssrParam === null || ssrParam === void 0 ? void 0 : ssrParam.ssr;
|
|
168
170
|
}
|
|
169
|
-
if (ssr && !
|
|
171
|
+
if (ssr && !resolvedEmitCssInSsr) {
|
|
170
172
|
return integration.transform({
|
|
171
173
|
source: code,
|
|
172
174
|
filePath: vite.normalizePath(validId),
|
|
@@ -199,7 +201,7 @@ function vanillaExtractPlugin({
|
|
|
199
201
|
fileScope,
|
|
200
202
|
source
|
|
201
203
|
}) => {
|
|
202
|
-
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr &&
|
|
204
|
+
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr && resolvedEmitCssInSsr ? virtualExtCss : virtualExtJs}`;
|
|
203
205
|
const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
|
|
204
206
|
let cssSource = source;
|
|
205
207
|
if (postCssConfig) {
|
|
@@ -69,13 +69,15 @@ const virtualExtCss = '.vanilla.css';
|
|
|
69
69
|
const virtualExtJs = '.vanilla.js';
|
|
70
70
|
function vanillaExtractPlugin({
|
|
71
71
|
identifiers,
|
|
72
|
+
emitCssInSsr,
|
|
72
73
|
esbuildOptions
|
|
73
74
|
} = {}) {
|
|
74
75
|
let config;
|
|
75
76
|
let server;
|
|
76
77
|
let postCssConfig;
|
|
77
78
|
const cssMap = new Map();
|
|
78
|
-
|
|
79
|
+
const hasEmitCssOverride = typeof emitCssInSsr === 'boolean';
|
|
80
|
+
let resolvedEmitCssInSsr = hasEmitCssOverride ? emitCssInSsr : !!process.env.VITE_RSC_BUILD;
|
|
79
81
|
let packageName;
|
|
80
82
|
const getAbsoluteVirtualFileId = source => vite.normalizePath(path__default["default"].join(config.root, source));
|
|
81
83
|
return {
|
|
@@ -101,8 +103,8 @@ function vanillaExtractPlugin({
|
|
|
101
103
|
if (config.command === 'serve') {
|
|
102
104
|
postCssConfig = await resolvePostcssConfig(config);
|
|
103
105
|
}
|
|
104
|
-
if (config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
105
|
-
|
|
106
|
+
if (!hasEmitCssOverride && config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
107
|
+
resolvedEmitCssInSsr = true;
|
|
106
108
|
}
|
|
107
109
|
},
|
|
108
110
|
resolveId(source) {
|
|
@@ -166,7 +168,7 @@ function vanillaExtractPlugin({
|
|
|
166
168
|
} else {
|
|
167
169
|
ssr = ssrParam === null || ssrParam === void 0 ? void 0 : ssrParam.ssr;
|
|
168
170
|
}
|
|
169
|
-
if (ssr && !
|
|
171
|
+
if (ssr && !resolvedEmitCssInSsr) {
|
|
170
172
|
return integration.transform({
|
|
171
173
|
source: code,
|
|
172
174
|
filePath: vite.normalizePath(validId),
|
|
@@ -199,7 +201,7 @@ function vanillaExtractPlugin({
|
|
|
199
201
|
fileScope,
|
|
200
202
|
source
|
|
201
203
|
}) => {
|
|
202
|
-
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr &&
|
|
204
|
+
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr && resolvedEmitCssInSsr ? virtualExtCss : virtualExtJs}`;
|
|
203
205
|
const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
|
|
204
206
|
let cssSource = source;
|
|
205
207
|
if (postCssConfig) {
|
|
@@ -42,13 +42,15 @@ const virtualExtCss = '.vanilla.css';
|
|
|
42
42
|
const virtualExtJs = '.vanilla.js';
|
|
43
43
|
function vanillaExtractPlugin({
|
|
44
44
|
identifiers,
|
|
45
|
+
emitCssInSsr,
|
|
45
46
|
esbuildOptions
|
|
46
47
|
} = {}) {
|
|
47
48
|
let config;
|
|
48
49
|
let server;
|
|
49
50
|
let postCssConfig;
|
|
50
51
|
const cssMap = new Map();
|
|
51
|
-
|
|
52
|
+
const hasEmitCssOverride = typeof emitCssInSsr === 'boolean';
|
|
53
|
+
let resolvedEmitCssInSsr = hasEmitCssOverride ? emitCssInSsr : !!process.env.VITE_RSC_BUILD;
|
|
52
54
|
let packageName;
|
|
53
55
|
const getAbsoluteVirtualFileId = source => normalizePath(path.join(config.root, source));
|
|
54
56
|
return {
|
|
@@ -74,8 +76,8 @@ function vanillaExtractPlugin({
|
|
|
74
76
|
if (config.command === 'serve') {
|
|
75
77
|
postCssConfig = await resolvePostcssConfig(config);
|
|
76
78
|
}
|
|
77
|
-
if (config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
78
|
-
|
|
79
|
+
if (!hasEmitCssOverride && config.plugins.some(plugin => ['astro:build', 'solid-start-server', 'vite-plugin-qwik', 'vite-plugin-svelte'].includes(plugin.name))) {
|
|
80
|
+
resolvedEmitCssInSsr = true;
|
|
79
81
|
}
|
|
80
82
|
},
|
|
81
83
|
resolveId(source) {
|
|
@@ -139,7 +141,7 @@ function vanillaExtractPlugin({
|
|
|
139
141
|
} else {
|
|
140
142
|
ssr = ssrParam === null || ssrParam === void 0 ? void 0 : ssrParam.ssr;
|
|
141
143
|
}
|
|
142
|
-
if (ssr && !
|
|
144
|
+
if (ssr && !resolvedEmitCssInSsr) {
|
|
143
145
|
return transform({
|
|
144
146
|
source: code,
|
|
145
147
|
filePath: normalizePath(validId),
|
|
@@ -172,7 +174,7 @@ function vanillaExtractPlugin({
|
|
|
172
174
|
fileScope,
|
|
173
175
|
source
|
|
174
176
|
}) => {
|
|
175
|
-
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr &&
|
|
177
|
+
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr && resolvedEmitCssInSsr ? virtualExtCss : virtualExtJs}`;
|
|
176
178
|
const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
|
|
177
179
|
let cssSource = source;
|
|
178
180
|
if (postCssConfig) {
|
package/package.json
CHANGED