Skip to content

Commit d88397f

Browse files
feat(tailwind): add setup-tailwind generator (#22)
* feat(tailwind): add setup-tailwind generator * feat: update setup-tailwind base files * feat(set-up-tailwind.ts): update style imports and test * feat: remove update project and add tailwind option in application and preset * feat: fix setup tailwind unit test issue * refactor: apply pr comments * refactor: cleanup * refactor: cleanup
1 parent 43d4dec commit d88397f

16 files changed

+376
-10
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@ it can be useful to publish to a local registry.
146146
- Run `npm i -g verdaccio` in Terminal 1 (keep it running)
147147
- Run `verdaccio
148148
- Run `npm adduser --registry http://localhost:4873` in Terminal 2 (real credentials are not required, you just need to be logged in. You can use your own login details.
149-
- Run `npm publish [package] --registry=http://localhost:4783`
149+
- Run `nx publish [package] --registry=http://localhost:4873`
150+
- Run `nx publish qwik-nx --registry=http://localhost:4873`
150151

151152
### ▶ 10. That's it! Thank you for your contribution! 🙏💓
152153

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ nx generate qwik-nx:lib
5555
nx generate qwik-nx:component
5656
```
5757

58+
### Setting up Tailwind CSS
59+
60+
```
61+
nx generate qwik-nx:setup-tailwind
62+
```
63+
5864
## ROADMAP:
5965

6066
- [ ] Complete generators for Route, Component and more

packages/qwik-nx/generators.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,42 @@
77
"factory": "./src/generators/application/generator",
88
"schema": "./src/generators/application/schema.json",
99
"description": "Qwik application generator",
10-
"aliases": ["app"]
10+
"aliases": ["app", "a"]
1111
},
1212
"init": {
1313
"factory": "./src/generators/init/init",
1414
"schema": "./src/generators/init/schema.json",
15-
"description": "qwik init plugin"
15+
"description": "Initialize the qwik-nx plugin",
16+
"aliases": ["i"]
1617
},
1718
"route": {
1819
"factory": "./src/generators/route/generator",
1920
"schema": "./src/generators/route/schema.json",
20-
"description": "Adding a Qwik City route"
21+
"description": "Adding a Qwik City route",
22+
"aliases": ["r"]
2123
},
2224
"component": {
2325
"factory": "./src/generators/component/generator",
2426
"schema": "./src/generators/component/schema.json",
25-
"description": "Generating a Qwik component"
27+
"description": "Generating a Qwik component",
28+
"aliases": ["cmp", "c"]
2629
},
2730
"library": {
2831
"factory": "./src/generators/library/generator",
2932
"schema": "./src/generators/library/schema.json",
30-
"description": "library generator",
31-
"aliases": ["lib"]
33+
"description": "Create a Qwik Library",
34+
"aliases": ["lib", "l"]
3235
},
3336
"preset": {
3437
"factory": "./src/generators/preset/generator",
3538
"schema": "./src/generators/preset/schema.json",
36-
"description": "preset generator"
39+
"description": "Create a Qwik Workspace Preset"
40+
},
41+
"setup-tailwind": {
42+
"factory": "./src/generators/setup-tailwind/setup-tailwind",
43+
"schema": "./src/generators/setup-tailwind/schema.json",
44+
"description": "Set up Tailwind configuration for a project.",
45+
"aliases": ["tailwind", "tw", "t"]
3746
}
3847
}
3948
}

packages/qwik-nx/src/generators/application/generator.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { SetupTailwindOptions } from './../setup-tailwind/schema.d';
12
import {
23
addProjectConfiguration,
34
formatFiles,
@@ -16,6 +17,7 @@ import { runTasksInSerial } from '@nrwl/workspace/src/utilities/run-tasks-in-ser
1617
import { configureEslint } from '../../utils/configure-eslint';
1718
import { addCommonQwikDependencies } from '../../utils/add-common-qwik-dependencies';
1819
import { updateQwikApplicationProjectParams } from './utils/update-qwik-application-project-params';
20+
import setupTailwindGenerator from '../setup-tailwind/setup-tailwind';
1921

2022
function addFiles(tree: Tree, options: NormalizedSchema) {
2123
const templateOptions = {
@@ -91,5 +93,12 @@ export default async function (tree: Tree, options: QwikAppGeneratorSchema) {
9193
await formatFiles(tree);
9294
}
9395

96+
if (options.tailwind) {
97+
const twOptions: SetupTailwindOptions = {
98+
project: normalizedOptions.name,
99+
};
100+
await setupTailwindGenerator(tree, twOptions);
101+
}
102+
94103
return runTasksInSerial(...tasks);
95104
}

packages/qwik-nx/src/generators/application/schema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface QwikAppGeneratorSchema {
66
style: 'css' | 'scss' | 'styl' | 'less' | 'none';
77
linter: 'eslint' | 'none';
88
skipFormat: boolean;
9+
tailwind?: boolean;
910
unitTestRunner: 'vitest' | 'none';
1011
strict: boolean;
1112
// router: 'qwik-city' | 'none'; // TODO: add setup w/o qwik-city

packages/qwik-nx/src/generators/preset/generator.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ describe('preset generator', () => {
88
let appTree: Tree;
99
const options: QwikWorkspacePresetGeneratorSchema = {
1010
name: 'test',
11+
qwikAppName: 'test',
12+
qwikAppStyle: 'css',
1113
style: 'css',
1214
linter: 'none',
1315
skipFormat: false,

packages/qwik-nx/src/generators/preset/schema.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
export interface QwikWorkspacePresetGeneratorSchema {
1+
export interface QwikWorkspacePresetGeneratorSchema
2+
extends QwikAppGeneratorSchema {
23
name: string;
34
qwikAppName: string;
45
tags?: string;
@@ -8,6 +9,7 @@ export interface QwikWorkspacePresetGeneratorSchema {
89
qwikAppStyle: 'css' | 'scss' | 'styl' | 'less' | 'none';
910
linter: 'eslint' | 'none';
1011
skipFormat: boolean;
12+
tailwind?: boolean;
1113
unitTestRunner: 'vitest' | 'none';
1214
strict: boolean;
1315
}

packages/qwik-nx/src/generators/preset/schema.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"$source": "argv",
1313
"index": 0
1414
},
15-
"x-prompt": "What name would you like to use?"
15+
"x-prompt": "App Name"
1616
},
1717
"tags": {
1818
"type": "string",
@@ -64,6 +64,11 @@
6464
"type": "boolean",
6565
"description": "Creates an application with strict mode and strict type checking.",
6666
"default": true
67+
},
68+
"tailwind": {
69+
"description": "Setup Tailwind",
70+
"type": "boolean",
71+
"default": false
6772
}
6873
},
6974
"required": ["name"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
autoprefixer: {},
5+
},
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
content: ['./src/**/*.{js,ts,jsx,tsx,mdx}'],
4+
theme: {
5+
extend: {},
6+
},
7+
plugins: [],
8+
};

0 commit comments

Comments
 (0)