uniwind-plugin-next 1.1.0 → 1.1.2
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 +10 -3
- package/dist/index.cjs +7 -5
- package/dist/index.mjs +7 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Tested on Next `16.1`, but other versions will likely work fine.
|
|
|
18
18
|
## Installation & setup
|
|
19
19
|
This setup guide assumes you already have a next.js project setup with Tailwind v4
|
|
20
20
|
|
|
21
|
-
1. Install uniwind and this plugin
|
|
21
|
+
1. Install uniwind and this plugin. You will probably also need `@expo/next-adapter` if you don't already have it, to handle react-native web support.
|
|
22
22
|
|
|
23
23
|
```shell
|
|
24
24
|
pnpm install uniwind uniwind-plugin-next @expo/next-adapter
|
|
@@ -47,8 +47,8 @@ export default withUniwind(withExpo(nextConfig), {
|
|
|
47
47
|
```js
|
|
48
48
|
const config = {
|
|
49
49
|
plugins: {
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
'@tailwindcss/postcss': {},
|
|
51
|
+
'uniwind-plugin-next/postcss': {}, // Add this line
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
54
|
|
|
@@ -75,6 +75,13 @@ return (
|
|
|
75
75
|
|
|
76
76
|
6. Start the dev server to generate `uniwind-types.d.ts`. Make sure that it's included in your `tsconfig.json`'s `include` array.
|
|
77
77
|
|
|
78
|
+
## SSR Considerations
|
|
79
|
+
- This plugin marks all Uniwind web components with `'use client'` automatically, so you do not need to do this manually.
|
|
80
|
+
|
|
81
|
+
- Be aware that some Uniwind features, such as `withUniwind` and `useResolveClassNames` will not work in a server environment, as they rely on accessing `window` or `document`.
|
|
82
|
+
|
|
83
|
+
-
|
|
84
|
+
|
|
78
85
|
## Known limitations
|
|
79
86
|
|
|
80
87
|
- This plugin uses a much more primitive regex-based postcss plugin for transforming Uniwind CSS functions (`pixelRatio()`, `fontScale()`, `hairlineWidth()`) compared to the official Vite plugin (which uses a full AST parser). As a result, some edge cases may not be handled correctly. If you do not use these functions in your CSS, this will not impact you. If you do run into any issues, please open an issue.
|
package/dist/index.cjs
CHANGED
|
@@ -257,12 +257,12 @@ const generateCSSForVariants = () => {
|
|
|
257
257
|
|
|
258
258
|
//#endregion
|
|
259
259
|
//#region src/webpack/uniwind/src/css/index.ts
|
|
260
|
-
const dirname = typeof __dirname !== "undefined" ? __dirname : __dirname;
|
|
260
|
+
const dirname$1 = typeof __dirname !== "undefined" ? __dirname : __dirname;
|
|
261
261
|
const buildCSS = async (themes, input) => {
|
|
262
262
|
const variants$1 = generateCSSForVariants();
|
|
263
263
|
const insets = generateCSSForInsets();
|
|
264
264
|
const themesCSS = await generateCSSForThemes(themes, input);
|
|
265
|
-
const cssFile = path.default.join(dirname, "../../uniwind.css");
|
|
265
|
+
const cssFile = path.default.join(dirname$1, "../../uniwind.css");
|
|
266
266
|
if ((fs.default.existsSync(cssFile) ? fs.default.readFileSync(cssFile, "utf-8") : "") === cssFile) return;
|
|
267
267
|
fs.default.writeFileSync(cssFile, [
|
|
268
268
|
variants$1,
|
|
@@ -302,6 +302,7 @@ const stringifyThemes = (themes = []) => `[${themes.map((theme) => `'${theme}'`)
|
|
|
302
302
|
|
|
303
303
|
//#endregion
|
|
304
304
|
//#region src/webpack/UniwindWebpackPlugin.ts
|
|
305
|
+
const dirname = typeof __dirname !== "undefined" ? __dirname : __dirname;
|
|
305
306
|
var UniwindWebpackPlugin = class {
|
|
306
307
|
constructor({ cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
307
308
|
this.hasRun = false;
|
|
@@ -327,14 +328,15 @@ var UniwindWebpackPlugin = class {
|
|
|
327
328
|
test: /config\.c?js$/,
|
|
328
329
|
include: /uniwind[\/\\]dist/,
|
|
329
330
|
use: [{
|
|
330
|
-
loader: path.default.resolve(
|
|
331
|
+
loader: path.default.resolve(dirname, "configInjectionLoader.js"),
|
|
331
332
|
options: { stringifiedThemes: stringifyThemes(this.themes) }
|
|
332
333
|
}]
|
|
333
334
|
});
|
|
334
335
|
compiler.options.module.rules.push({
|
|
335
|
-
test:
|
|
336
|
+
test: /\.js$/,
|
|
337
|
+
exclude: /index\.js$/,
|
|
336
338
|
include: /uniwind[\/\\]dist[\/\\]module[\/\\]components[\/\\]web/,
|
|
337
|
-
use: [{ loader: path.default.resolve(
|
|
339
|
+
use: [{ loader: path.default.resolve(dirname, "clientDirectiveLoader.js") }]
|
|
338
340
|
});
|
|
339
341
|
}
|
|
340
342
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -228,12 +228,12 @@ const generateCSSForVariants = () => {
|
|
|
228
228
|
|
|
229
229
|
//#endregion
|
|
230
230
|
//#region src/webpack/uniwind/src/css/index.ts
|
|
231
|
-
const dirname = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
231
|
+
const dirname$1 = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
232
232
|
const buildCSS = async (themes, input) => {
|
|
233
233
|
const variants$1 = generateCSSForVariants();
|
|
234
234
|
const insets = generateCSSForInsets();
|
|
235
235
|
const themesCSS = await generateCSSForThemes(themes, input);
|
|
236
|
-
const cssFile = path.join(dirname, "../../uniwind.css");
|
|
236
|
+
const cssFile = path.join(dirname$1, "../../uniwind.css");
|
|
237
237
|
if ((fs.existsSync(cssFile) ? fs.readFileSync(cssFile, "utf-8") : "") === cssFile) return;
|
|
238
238
|
fs.writeFileSync(cssFile, [
|
|
239
239
|
variants$1,
|
|
@@ -273,6 +273,7 @@ const stringifyThemes = (themes = []) => `[${themes.map((theme) => `'${theme}'`)
|
|
|
273
273
|
|
|
274
274
|
//#endregion
|
|
275
275
|
//#region src/webpack/UniwindWebpackPlugin.ts
|
|
276
|
+
const dirname = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
276
277
|
var UniwindWebpackPlugin = class {
|
|
277
278
|
constructor({ cssEntryFile, extraThemes = [], dtsFile = "uniwind-types.d.ts" }) {
|
|
278
279
|
this.hasRun = false;
|
|
@@ -298,14 +299,15 @@ var UniwindWebpackPlugin = class {
|
|
|
298
299
|
test: /config\.c?js$/,
|
|
299
300
|
include: /uniwind[\/\\]dist/,
|
|
300
301
|
use: [{
|
|
301
|
-
loader: path.resolve(
|
|
302
|
+
loader: path.resolve(dirname, "configInjectionLoader.js"),
|
|
302
303
|
options: { stringifiedThemes: stringifyThemes(this.themes) }
|
|
303
304
|
}]
|
|
304
305
|
});
|
|
305
306
|
compiler.options.module.rules.push({
|
|
306
|
-
test:
|
|
307
|
+
test: /\.js$/,
|
|
308
|
+
exclude: /index\.js$/,
|
|
307
309
|
include: /uniwind[\/\\]dist[\/\\]module[\/\\]components[\/\\]web/,
|
|
308
|
-
use: [{ loader: path.resolve(
|
|
310
|
+
use: [{ loader: path.resolve(dirname, "clientDirectiveLoader.js") }]
|
|
309
311
|
});
|
|
310
312
|
}
|
|
311
313
|
};
|