Implement a Tailwind content path wrapper (#1731)

This commit is contained in:
Mihovil Ilakovac 2024-02-09 13:10:37 +01:00 committed by GitHub
parent b873df960d
commit c9959b4515
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 78 additions and 11 deletions

View File

@ -1,6 +1,8 @@
const { resolveProjectPath } = require('wasp/client')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{js,ts,jsx,tsx}'],
content: [resolveProjectPath('./src/**/*.{js,ts,jsx,tsx}')],
theme: {
extend: {
skew: {

View File

@ -1,7 +1,9 @@
const { resolveProjectPath } = require('wasp/client')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
resolveProjectPath('./src/**/*.{js,jsx,ts,tsx}'),
],
corePlugins: {
//preflight: false

View File

@ -1,8 +1,10 @@
const { resolveProjectPath } = require('wasp/client')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
"node_modules/flowbite-react/**/*.{js,jsx,ts,tsx}",
resolveProjectPath("./src/**/*.{js,jsx,ts,tsx}"),
resolveProjectPath("node_modules/flowbite-react/**/*.{js,jsx,ts,tsx}"),
],
theme: {
extend: {},

View File

@ -0,0 +1,11 @@
import * as path from 'path';
// PUBLIC API
/**
* Wasp runs the client code in the `web-app` directory which is nested in the
* .wasp/out/web-app directory. This function resolves a project root dir path
* to be relative to the `web-app` directory i.e. `../../../projectDirPath`.
*/
export function resolveProjectPath(path: string): string {
return path.join('../../../', path);
}

View File

@ -109,7 +109,8 @@
"./server/jobs": "./dist/server/jobs/index.js",
"./server/operations": "./dist/server/operations/index.js",
"./client/router": "./dist/client/router/index.js",
"./client/test": "./dist/client/test/index.js"
"./client/test": "./dist/client/test/index.js",
"./client": "./dist/client/index.js"
},
{=!
TypeScript doesn't care about the redirects we define above in "exports" field; those

View File

@ -1,10 +1,11 @@
const { resolveProjectPath } = require('wasp/client')
const { nextui } = require("@nextui-org/react");
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
"./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}",
resolveProjectPath("./src/**/*.{js,jsx,ts,tsx}"),
resolveProjectPath("./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}"),
],
theme: {
extend: {},

View File

@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

View File

@ -1,3 +1,7 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
* {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
@ -71,3 +75,23 @@ li {
justify-content: space-between;
align-items: center;
}
.button {
@apply bg-cyan-500 text-white font-bold py-2 px-4 rounded;
}
a {
@apply text-cyan-500 underline;
}
input {
@apply border border-gray-400 rounded p-2;
}
h1 {
@apply text-3xl font-bold;
}
h2 {
@apply text-2xl font-bold;
}

View File

@ -0,0 +1,10 @@
const { resolveProjectPath } = require('wasp/client')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [resolveProjectPath('./src/**/*.{js,jsx,ts,tsx}')],
theme: {
extend: {},
},
plugins: [],
}

View File

@ -1,7 +1,9 @@
const { resolveProjectPath } = require('wasp/client')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
resolveProjectPath("./src/**/*.{js,jsx,ts,tsx}"),
],
theme: {
extend: {},

View File

@ -1,7 +1,9 @@
const { resolveProjectPath } = require('wasp/client')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
resolveProjectPath("./src/**/*.{js,jsx,ts,tsx}"),
],
theme: {
extend: {},

View File

@ -296,12 +296,13 @@ generateTailwindConfigFile :: NewProjectDetails -> File
generateTailwindConfigFile newProjectDetails =
( "tailwind.config.cjs",
[trimming|
const { resolveProjectPath } = require('wasp/client')
const colors = require('tailwindcss/colors')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
resolveProjectPath('./src/**/*.{js,jsx,ts,tsx}'),
],
theme: {
extend: {

View File

@ -88,6 +88,7 @@ genSdkReal spec =
genFileCopy [relfile|types/index.ts|],
genFileCopy [relfile|client/test/vitest/helpers.tsx|],
genFileCopy [relfile|client/test/index.ts|],
genFileCopy [relfile|client/index.ts|],
genServerConfigFile spec,
genTsConfigJson,
genServerUtils spec,

View File

@ -40,9 +40,11 @@ Make sure to use the `.cjs` extension for these config files, if you name them w
1. Add `./tailwind.config.cjs`.
```js title="./tailwind.config.cjs"
const { resolveProjectPath } = require('wasp/client')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [ "./src/**/*.{js,jsx,ts,tsx}" ],
content: [resolveProjectPath('./src/**/*.{js,jsx,ts,tsx}')],
theme: {
extend: {},
},