@zubyjs/tailwind 1.0.56
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 +63 -0
- package/examples/js/tailwind.config.mjs +8 -0
- package/examples/ts/tailwind.config.ts +9 -0
- package/index.d.ts +25 -0
- package/index.js +53 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @zubyjs/tailwind
|
|
2
|
+
|
|
3
|
+
The plugin for Zuby.js that offers seamless integration with [Tailwind CSS](https://tailwindcss.com/)
|
|
4
|
+
for your application.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
First, install the `@zubyjs/tailwind` package using your favorite package manager.
|
|
9
|
+
If you aren't sure, you can use npm:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install @zubyjs/tailwind
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then add the `@zubyjs/tailwind` plugin to your `zuby.config.mjs` file under the `plugins` option:
|
|
16
|
+
|
|
17
|
+
```diff lang="js" title="zuby.config.mjs"
|
|
18
|
+
import { defineConfig } from 'zuby';
|
|
19
|
+
import preact from '@zubyjs/preact';
|
|
20
|
+
+ import tailwind from '@zubyjs/tailwind';
|
|
21
|
+
|
|
22
|
+
export default defineConfig({
|
|
23
|
+
outDir: '.zuby',
|
|
24
|
+
jsx: preact(),
|
|
25
|
+
+ plugins: [
|
|
26
|
+
+ tailwind()
|
|
27
|
+
+ ]
|
|
28
|
+
^^^^^^^^
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The plugin will add the Tailwind CSS to your application and create the `tailwind.config.mjs` file during the build if it doesn't exist yet.
|
|
33
|
+
You just need to add below basic Tailwind CSS to your main CSS file:
|
|
34
|
+
|
|
35
|
+
```css title="src/index.css"
|
|
36
|
+
@tailwind base;
|
|
37
|
+
@tailwind components;
|
|
38
|
+
@tailwind utilities;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
And that's it! You are ready to use Tailwind CSS in your application.
|
|
42
|
+
|
|
43
|
+
NOTE: Always make sure that all zuby packages are in sync in your `package.json` file:
|
|
44
|
+
|
|
45
|
+
```diff lang="json"
|
|
46
|
+
{
|
|
47
|
+
"name": "my-zuby-app",
|
|
48
|
+
"version": "1.0.0",
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"zuby": "latest",
|
|
51
|
+
"@zubyjs/tailwind": "latest"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Contributing
|
|
57
|
+
|
|
58
|
+
This package is part of Zuby.js workspace and maintained by the team behind the [Zuby package](https://www.npmjs.com/package/zuby).
|
|
59
|
+
Please refer to it for more details how to contribute.
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ZubyPlugin } from 'zuby/types.js';
|
|
2
|
+
export declare const TAILWIND_CONFIG_FILE = "tailwind.config.js";
|
|
3
|
+
export interface TailwindPluginOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Relative path to config file for Tailwind CSS.
|
|
6
|
+
* @default 'tailwind.config.mjs' or 'tailwind.config.ts'
|
|
7
|
+
*/
|
|
8
|
+
configFile?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Set to true to enable support
|
|
11
|
+
* for nested declarations using tailwindcss/nesting plugin.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
nesting?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Zuby.js plugin that integrates Tailwind CSS
|
|
18
|
+
* with your application.
|
|
19
|
+
* @param options
|
|
20
|
+
* @returns ZubyPlugin
|
|
21
|
+
*/
|
|
22
|
+
declare const _default: ({ configFile, nesting }?: TailwindPluginOptions) => ZubyPlugin;
|
|
23
|
+
export default _default;
|
|
24
|
+
export declare function createTailwindConfig(srcDir: string): string;
|
|
25
|
+
export declare function findTailwindConfig(srcDir: string): string | undefined;
|
package/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { dirname, resolve } from 'path';
|
|
2
|
+
import { existsSync, copyFileSync } from 'fs';
|
|
3
|
+
import { fileURLToPath } from 'url';
|
|
4
|
+
import tailwindcssPlugin from 'tailwindcss';
|
|
5
|
+
import autoprefixerPlugin from 'autoprefixer';
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = dirname(__filename);
|
|
8
|
+
export const TAILWIND_CONFIG_FILE = 'tailwind.config.js';
|
|
9
|
+
/**
|
|
10
|
+
* Zuby.js plugin that integrates Tailwind CSS
|
|
11
|
+
* with your application.
|
|
12
|
+
* @param options
|
|
13
|
+
* @returns ZubyPlugin
|
|
14
|
+
*/
|
|
15
|
+
export default ({ configFile, nesting = false } = {}) => ({
|
|
16
|
+
name: 'zuby-tailwind-plugin',
|
|
17
|
+
description: 'Adds Tailwind CSS to your Zuby.js application',
|
|
18
|
+
hooks: {
|
|
19
|
+
'zuby:config:setup': async ({ config, injectToEntry }) => {
|
|
20
|
+
const { srcDir = './' } = config;
|
|
21
|
+
configFile = configFile || findTailwindConfig(srcDir) || createTailwindConfig(srcDir);
|
|
22
|
+
config.vite = config.vite || {};
|
|
23
|
+
config.vite.css = config.vite?.css || {};
|
|
24
|
+
config.vite.css.postcss = config.vite.css.postcss || {};
|
|
25
|
+
if (typeof config.vite.css.postcss === 'string') {
|
|
26
|
+
console.error(`[zuby-tailwind-plugin] Invalid configuration for 'vite.css.postcss'. Expected an object, but got a string.`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
config.vite.css.postcss.plugins = config.vite.css.postcss.plugins || [];
|
|
30
|
+
config.vite.css.postcss.plugins.push(tailwindcssPlugin(configFile), autoprefixerPlugin());
|
|
31
|
+
if (nesting) {
|
|
32
|
+
const tailwindcssNestingPlugin = (await import('tailwindcss/nesting/index.js')).default;
|
|
33
|
+
config.vite.css.postcss.plugins.push(tailwindcssNestingPlugin());
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export function createTailwindConfig(srcDir) {
|
|
39
|
+
const isTs = existsSync(resolve(srcDir, 'tsconfig.json'));
|
|
40
|
+
const configFile = isTs
|
|
41
|
+
? TAILWIND_CONFIG_FILE.replace('.js', '.ts')
|
|
42
|
+
: TAILWIND_CONFIG_FILE.replace('.js', '.mjs');
|
|
43
|
+
copyFileSync(resolve(__dirname, 'examples', isTs ? 'ts' : 'js', configFile), resolve(srcDir, configFile));
|
|
44
|
+
return configFile;
|
|
45
|
+
}
|
|
46
|
+
export function findTailwindConfig(srcDir) {
|
|
47
|
+
return [
|
|
48
|
+
resolve(srcDir, TAILWIND_CONFIG_FILE),
|
|
49
|
+
resolve(srcDir, TAILWIND_CONFIG_FILE.replace('.js', '.mjs')),
|
|
50
|
+
resolve(srcDir, TAILWIND_CONFIG_FILE.replace('.js', '.cjs')),
|
|
51
|
+
resolve(srcDir, TAILWIND_CONFIG_FILE.replace('.js', '.ts')),
|
|
52
|
+
].find(file => existsSync(file));
|
|
53
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zubyjs/tailwind",
|
|
3
|
+
"version": "1.0.56",
|
|
4
|
+
"description": "Zuby.js tailwind plugin",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"release": "cd ./dist && npm publish --access public && cd ..",
|
|
9
|
+
"bump-version": "npm version patch",
|
|
10
|
+
"build": "rm -rf dist/ stage/ && mkdir dist && tsc && cp -rf package.json README.md src/examples stage/tailwind/src/* dist/ && rm -rf stage/",
|
|
11
|
+
"push-build": "npm run build && cd dist && yalc push --force && cd ..",
|
|
12
|
+
"test": "exit 0"
|
|
13
|
+
},
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"directory": "dist",
|
|
16
|
+
"linkDirectory": true
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"autoprefixer": "^10.4.17",
|
|
20
|
+
"tailwindcss": "^3.4.1"
|
|
21
|
+
},
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"zuby": "^1.0.0"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://gitlab.com/futrou/zuby.js/-/issues",
|
|
27
|
+
"email": "zuby@futrou.com"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://gitlab.com/futrou/zuby.js.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://zubyjs.com",
|
|
35
|
+
"keywords": [
|
|
36
|
+
"zuby-plugin",
|
|
37
|
+
"zuby",
|
|
38
|
+
"tailwind",
|
|
39
|
+
"css"
|
|
40
|
+
],
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18"
|
|
43
|
+
}
|
|
44
|
+
}
|