@vanilla-extract/vite-plugin 3.3.1 → 3.5.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.
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ document.write(`
|
|
|
74
74
|
|
|
75
75
|
---
|
|
76
76
|
|
|
77
|
-
Want to work at a higher level while maximising style re-use? Check out 🍨 [Sprinkles](https://vanilla-extract.style/documentation/sprinkles
|
|
77
|
+
Want to work at a higher level while maximising style re-use? Check out 🍨 [Sprinkles](https://vanilla-extract.style/documentation/packages/sprinkles), our official zero-runtime atomic CSS framework, built on top of vanilla-extract.
|
|
78
78
|
|
|
79
79
|
---
|
|
80
80
|
|
|
@@ -1044,7 +1044,7 @@ document.write(`
|
|
|
1044
1044
|
|
|
1045
1045
|
Your recipe configuration can also make use of existing variables, classes and styles.
|
|
1046
1046
|
|
|
1047
|
-
For example, you can pass in the result of your [`sprinkles`](https://vanilla-extract.style/documentation/sprinkles
|
|
1047
|
+
For example, you can pass in the result of your [`sprinkles`](https://vanilla-extract.style/documentation/packages/sprinkles) function directly.
|
|
1048
1048
|
|
|
1049
1049
|
```ts
|
|
1050
1050
|
import { recipe } from '@vanilla-extract/recipes';
|
|
@@ -68,6 +68,8 @@ const resolvePostcssConfig = async config => {
|
|
|
68
68
|
|
|
69
69
|
const styleUpdateEvent = fileId => `vanilla-extract-style-update:${fileId}`;
|
|
70
70
|
|
|
71
|
+
const virtualExtCss = '.vanilla.css';
|
|
72
|
+
const virtualExtJs = '.vanilla.js';
|
|
71
73
|
function vanillaExtractPlugin({
|
|
72
74
|
identifiers,
|
|
73
75
|
esbuildOptions
|
|
@@ -76,7 +78,7 @@ function vanillaExtractPlugin({
|
|
|
76
78
|
let server;
|
|
77
79
|
let postCssConfig;
|
|
78
80
|
const cssMap = new Map();
|
|
79
|
-
let
|
|
81
|
+
let forceEmitCssInSsrBuild = !!process.env.VITE_RSC_BUILD;
|
|
80
82
|
let packageName;
|
|
81
83
|
|
|
82
84
|
const getAbsoluteVirtualFileId = source => vite.normalizePath(path__default["default"].join(config.root, source));
|
|
@@ -109,13 +111,15 @@ function vanillaExtractPlugin({
|
|
|
109
111
|
postCssConfig = await resolvePostcssConfig(config);
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
|
|
114
|
+
if (config.plugins.some(plugin => ['astro:build', 'solid-start-server'].includes(plugin.name))) {
|
|
115
|
+
forceEmitCssInSsrBuild = true;
|
|
116
|
+
}
|
|
113
117
|
},
|
|
114
118
|
|
|
115
119
|
resolveId(source) {
|
|
116
120
|
const [validId, query] = source.split('?');
|
|
117
121
|
|
|
118
|
-
if (!validId.endsWith(
|
|
122
|
+
if (!validId.endsWith(virtualExtCss) && !validId.endsWith(virtualExtJs)) {
|
|
119
123
|
return;
|
|
120
124
|
} // Absolute paths seem to occur often in monorepos, where files are
|
|
121
125
|
// imported from outside the config root.
|
|
@@ -144,7 +148,7 @@ function vanillaExtractPlugin({
|
|
|
144
148
|
return;
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
if (
|
|
151
|
+
if (validId.endsWith(virtualExtCss)) {
|
|
148
152
|
return css;
|
|
149
153
|
}
|
|
150
154
|
|
|
@@ -183,7 +187,7 @@ function vanillaExtractPlugin({
|
|
|
183
187
|
ssr = ssrParam === null || ssrParam === void 0 ? void 0 : ssrParam.ssr;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
|
-
if (ssr && !
|
|
190
|
+
if (ssr && !forceEmitCssInSsrBuild) {
|
|
187
191
|
return integration.addFileScope({
|
|
188
192
|
source: code,
|
|
189
193
|
filePath: vite.normalizePath(validId),
|
|
@@ -217,7 +221,7 @@ function vanillaExtractPlugin({
|
|
|
217
221
|
fileScope,
|
|
218
222
|
source
|
|
219
223
|
}) => {
|
|
220
|
-
const rootRelativeId = `${fileScope.filePath}${
|
|
224
|
+
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr && forceEmitCssInSsrBuild ? virtualExtCss : virtualExtJs}`;
|
|
221
225
|
const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
|
|
222
226
|
let cssSource = source;
|
|
223
227
|
|
|
@@ -68,6 +68,8 @@ const resolvePostcssConfig = async config => {
|
|
|
68
68
|
|
|
69
69
|
const styleUpdateEvent = fileId => `vanilla-extract-style-update:${fileId}`;
|
|
70
70
|
|
|
71
|
+
const virtualExtCss = '.vanilla.css';
|
|
72
|
+
const virtualExtJs = '.vanilla.js';
|
|
71
73
|
function vanillaExtractPlugin({
|
|
72
74
|
identifiers,
|
|
73
75
|
esbuildOptions
|
|
@@ -76,7 +78,7 @@ function vanillaExtractPlugin({
|
|
|
76
78
|
let server;
|
|
77
79
|
let postCssConfig;
|
|
78
80
|
const cssMap = new Map();
|
|
79
|
-
let
|
|
81
|
+
let forceEmitCssInSsrBuild = !!process.env.VITE_RSC_BUILD;
|
|
80
82
|
let packageName;
|
|
81
83
|
|
|
82
84
|
const getAbsoluteVirtualFileId = source => vite.normalizePath(path__default["default"].join(config.root, source));
|
|
@@ -109,13 +111,15 @@ function vanillaExtractPlugin({
|
|
|
109
111
|
postCssConfig = await resolvePostcssConfig(config);
|
|
110
112
|
}
|
|
111
113
|
|
|
112
|
-
|
|
114
|
+
if (config.plugins.some(plugin => ['astro:build', 'solid-start-server'].includes(plugin.name))) {
|
|
115
|
+
forceEmitCssInSsrBuild = true;
|
|
116
|
+
}
|
|
113
117
|
},
|
|
114
118
|
|
|
115
119
|
resolveId(source) {
|
|
116
120
|
const [validId, query] = source.split('?');
|
|
117
121
|
|
|
118
|
-
if (!validId.endsWith(
|
|
122
|
+
if (!validId.endsWith(virtualExtCss) && !validId.endsWith(virtualExtJs)) {
|
|
119
123
|
return;
|
|
120
124
|
} // Absolute paths seem to occur often in monorepos, where files are
|
|
121
125
|
// imported from outside the config root.
|
|
@@ -144,7 +148,7 @@ function vanillaExtractPlugin({
|
|
|
144
148
|
return;
|
|
145
149
|
}
|
|
146
150
|
|
|
147
|
-
if (
|
|
151
|
+
if (validId.endsWith(virtualExtCss)) {
|
|
148
152
|
return css;
|
|
149
153
|
}
|
|
150
154
|
|
|
@@ -183,7 +187,7 @@ function vanillaExtractPlugin({
|
|
|
183
187
|
ssr = ssrParam === null || ssrParam === void 0 ? void 0 : ssrParam.ssr;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
|
-
if (ssr && !
|
|
190
|
+
if (ssr && !forceEmitCssInSsrBuild) {
|
|
187
191
|
return integration.addFileScope({
|
|
188
192
|
source: code,
|
|
189
193
|
filePath: vite.normalizePath(validId),
|
|
@@ -217,7 +221,7 @@ function vanillaExtractPlugin({
|
|
|
217
221
|
fileScope,
|
|
218
222
|
source
|
|
219
223
|
}) => {
|
|
220
|
-
const rootRelativeId = `${fileScope.filePath}${
|
|
224
|
+
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr && forceEmitCssInSsrBuild ? virtualExtCss : virtualExtJs}`;
|
|
221
225
|
const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
|
|
222
226
|
let cssSource = source;
|
|
223
227
|
|
|
@@ -41,6 +41,8 @@ const resolvePostcssConfig = async config => {
|
|
|
41
41
|
|
|
42
42
|
const styleUpdateEvent = fileId => `vanilla-extract-style-update:${fileId}`;
|
|
43
43
|
|
|
44
|
+
const virtualExtCss = '.vanilla.css';
|
|
45
|
+
const virtualExtJs = '.vanilla.js';
|
|
44
46
|
function vanillaExtractPlugin({
|
|
45
47
|
identifiers,
|
|
46
48
|
esbuildOptions
|
|
@@ -49,7 +51,7 @@ function vanillaExtractPlugin({
|
|
|
49
51
|
let server;
|
|
50
52
|
let postCssConfig;
|
|
51
53
|
const cssMap = new Map();
|
|
52
|
-
let
|
|
54
|
+
let forceEmitCssInSsrBuild = !!process.env.VITE_RSC_BUILD;
|
|
53
55
|
let packageName;
|
|
54
56
|
|
|
55
57
|
const getAbsoluteVirtualFileId = source => normalizePath(path.join(config.root, source));
|
|
@@ -82,13 +84,15 @@ function vanillaExtractPlugin({
|
|
|
82
84
|
postCssConfig = await resolvePostcssConfig(config);
|
|
83
85
|
}
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
if (config.plugins.some(plugin => ['astro:build', 'solid-start-server'].includes(plugin.name))) {
|
|
88
|
+
forceEmitCssInSsrBuild = true;
|
|
89
|
+
}
|
|
86
90
|
},
|
|
87
91
|
|
|
88
92
|
resolveId(source) {
|
|
89
93
|
const [validId, query] = source.split('?');
|
|
90
94
|
|
|
91
|
-
if (!validId.endsWith(
|
|
95
|
+
if (!validId.endsWith(virtualExtCss) && !validId.endsWith(virtualExtJs)) {
|
|
92
96
|
return;
|
|
93
97
|
} // Absolute paths seem to occur often in monorepos, where files are
|
|
94
98
|
// imported from outside the config root.
|
|
@@ -117,7 +121,7 @@ function vanillaExtractPlugin({
|
|
|
117
121
|
return;
|
|
118
122
|
}
|
|
119
123
|
|
|
120
|
-
if (
|
|
124
|
+
if (validId.endsWith(virtualExtCss)) {
|
|
121
125
|
return css;
|
|
122
126
|
}
|
|
123
127
|
|
|
@@ -156,7 +160,7 @@ function vanillaExtractPlugin({
|
|
|
156
160
|
ssr = ssrParam === null || ssrParam === void 0 ? void 0 : ssrParam.ssr;
|
|
157
161
|
}
|
|
158
162
|
|
|
159
|
-
if (ssr && !
|
|
163
|
+
if (ssr && !forceEmitCssInSsrBuild) {
|
|
160
164
|
return addFileScope({
|
|
161
165
|
source: code,
|
|
162
166
|
filePath: normalizePath(validId),
|
|
@@ -190,7 +194,7 @@ function vanillaExtractPlugin({
|
|
|
190
194
|
fileScope,
|
|
191
195
|
source
|
|
192
196
|
}) => {
|
|
193
|
-
const rootRelativeId = `${fileScope.filePath}${
|
|
197
|
+
const rootRelativeId = `${fileScope.filePath}${config.command === 'build' || ssr && forceEmitCssInSsrBuild ? virtualExtCss : virtualExtJs}`;
|
|
194
198
|
const absoluteId = getAbsoluteVirtualFileId(rootRelativeId);
|
|
195
199
|
let cssSource = source;
|
|
196
200
|
|
package/package.json
CHANGED