Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tailwindcss experience #2015

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/nine-dots-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farmfe/js-plugin-tailwindcss": patch
---

feat: support tailwindcss plugin
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
"Kostiantyn",
"libfarmfe",
"libloading",
"lightningcss",
"linebpos",
"linechpos",
"loglevel",
Expand Down
8 changes: 8 additions & 0 deletions examples/tailwind-next/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"root": true,
"extends": "../../.eslintrc.base.json",
"parserOptions": {
"project": ["./examples/tailwind/tsconfig.json"]
},
"rules": {}
}
3 changes: 3 additions & 0 deletions examples/tailwind-next/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
build
node_modules
6 changes: 6 additions & 0 deletions examples/tailwind-next/.postcssrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"plugins": {
"tailwindcss": {},
"autoprefixer": {}
}
}
1 change: 1 addition & 0 deletions examples/tailwind-next/assets/feature.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/tailwind-next/assets/light.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/tailwind-next/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/tailwind-next/assets/plugin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions examples/tailwind-next/farm.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { UserConfig } from "@farmfe/core";
// import farmPostcssPlugin from '@farmfe/js-plugin-postcss';
import tailwind from "@farmfe/js-plugin-tailwindcss";

function defineConfig(config: UserConfig) {
return config;
}

export default defineConfig({
compilation: {
input: {
index: "./index.html",
},
output: {
path: "./build",
},
sourcemap: false,
resolve: {
dedupe: ["tailwindcss"],
},
},
server: {
hmr: true,
},
plugins: [
"@farmfe/plugin-react",
tailwind()
],
});
13 changes: 13 additions & 0 deletions examples/tailwind-next/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="root"></div>
<script src="./src/index.tsx"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions examples/tailwind-next/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "@farmfe-examples/tailwind-next",
"version": "0.0.2",
"private": true,
"dependencies": {
"@farmfe/js-plugin-tailwindcss": "workspace:^",
"clsx": "^1.2.1",
"core-js": "^3.30.1",
"react": "18",
"react-dom": "18"
},
"devDependencies": {
"@farmfe/cli": "workspace:*",
"@farmfe/core": "workspace:*",
"@farmfe/js-plugin-postcss": "workspace:*",
"@farmfe/plugin-react": "workspace:*",
"@types/react": "18",
"@types/react-dom": "18",
"autoprefixer": "^10.4.14",
"react-refresh": "^0.14.0",
"tailwindcss": "4.0.0-alpha.26"
},
"scripts": {
"start": "farm start",
"build": "farm build",
"preview": "farm preview"
}
}
35 changes: 35 additions & 0 deletions examples/tailwind-next/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import logo from './logo.svg?url';
import { useState } from 'react';

const App = () => {
const [count, setCount] = useState(0);

return (
<div className="text-center">
<header className="bg-slate-700 min-h-screen flex flex-col items-center justify-center text-[calc(10px + 2vmin)] text-white">
<img
src={logo}
className="animate-spin h-[20vmin] pointer-events-none"
alt="logo"
/>
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="text-red-600 text-[28px]"
href="https://github.com/tailwindcss/tailwindcss"
target="_blank"
rel="noopener noreferrer"
>
Learn Tailwindcss
</a>
<button className="mt-6" onClick={() => setCount(count + 1)}>
Count: {count}
</button>
</header>
</div>
);
};

export default App;
1 change: 1 addition & 0 deletions examples/tailwind-next/src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'tailwindcss';
9 changes: 9 additions & 0 deletions examples/tailwind-next/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import App from './App';
import './index.css';

const container = document.querySelector('#root');
const root = createRoot(container);

root.render(<App />);
4 changes: 4 additions & 0 deletions examples/tailwind-next/src/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/tailwind-next/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module '*.svg';
declare module '*.css';
declare module '*.png';
12 changes: 12 additions & 0 deletions examples/tailwind-next/tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}

11 changes: 11 additions & 0 deletions examples/tailwind-next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"noEmit": true,
"jsx": "react"
},
"include": ["src", "farm.config.ts"]
}
24 changes: 24 additions & 0 deletions js-plugins/tailwindcss/farm.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from '@farmfe/core';
import dts from '@farmfe/js-plugin-dts';

export default defineConfig({
compilation: {
input: {
index: './src/index.ts'
},
output: {
targetEnv: 'node',
format: 'esm'
},
external: ['@farmfe/core', '@tailwindcss/oxide', 'lightningcss'],
resolve: {
autoExternalFailedResolve: true,
dedupe: ['tailwindcss']
},
mode: 'development',
minify: false,
lazyCompilation: false,
treeShaking: false
},
plugins: [dts()]
});
35 changes: 35 additions & 0 deletions js-plugins/tailwindcss/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "@farmfe/js-plugin-tailwindcss",
"version": "0.0.1",
"description": "support tailwindcss for farm.",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "npx farm build",
"watch": "npx farm watch"
},
"keywords": [
"farm",
"@farmfe/core",
"farmfe",
"tailwindcss",
"css",
"atomic"
],
"author": "",
"license": "MIT",
"dependencies": {
"@farmfe/core": "workspace:^",
"@tailwindcss/node": "4.0.0-beta.8",
"@tailwindcss/oxide": "4.0.0-beta.8",
"lightningcss": "^1.27.0",
"postcss": "^8.4.47",
"postcss-import": "^16.0.1",
"tailwindcss": "4.0.0-beta.8"
},
"devDependencies": {
"@farmfe/js-plugin-dts": "workspace:^",
"@types/postcss-import": "^14.0.3"
}
}
Loading
Loading