Closed ajatib closed 3 years ago
@ajatib This looks like a problem with your PostCSS config.
Please make sure you have required plugins in your postcss.config.js
file.
Your postcss.config.js
config must look something like this:
module.exports = {
plugins: [
require('postcss-import'),
require('postcss-nested'),
require('tailwindcss'),
]
}
Also, I'm not sure why you installed postcss as a dev dependency, but the plugins are normal dependencies.
Thanks for your quick response @saadeghi.
postcss is there becouse tailwindcss npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
but I can change it.
My postcss.config.js is the following:
const tailwindcss = require('tailwindcss');
module.exports = {
plugins: [
require('postcss-import'),
tailwindcss('./tailwind.config.js'),
require('postcss-nested'), // or require('postcss-nesting')
require('autoprefixer'),
],
};
I will test reordering the plugins
Same results:
Creating an optimized production build...
Failed to compile.
./src/assets/css/main.css
ParserError: Syntax Error at line: 1, column 19
(full package.json)
{
"name": "app_mobile",
"version": "0.1.0",
"private": true,
"dependencies": {
"@headlessui/react": "^0.2.0",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"axios": "^0.21.0",
"daisyui": "^0.27.2",
"date-fns": "^2.16.1",
"date-fns-tz": "^1.1.3",
"downshift": "^6.1.0",
"final-form": "^4.20.1",
"final-form-arrays": "^3.0.2",
"final-form-calculate": "^1.3.2",
"final-form-set-field-data": "^1.0.2",
"geonames.js": "^3.0.3",
"i18next": "^19.8.5",
"i18next-browser-languagedetector": "^6.0.1",
"i18next-http-backend": "^1.1.0",
"match-sorter": "^6.1.0",
"postcss-import": "^14.0.2",
"postcss-nested": "^5.0.5",
"postcss": "^8.2.15",
"postcss-cli": "^8.3.1",
"public-ip": "^4.0.3",
"react": "^17.0.2",
"react-device-detect": "^1.15.0",
"react-dom": "^17.0.2",
"react-final-form": "^6.5.2",
"react-final-form-arrays": "^3.1.3",
"react-final-form-listeners": "^1.0.3",
"react-i18next": "^11.8.5",
"react-redux": "^7.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "^2.0.5",
"react-simple-pull-to-refresh": "^1.2.3",
"react-social-login": "^3.4.13",
"react-toastify": "^6.1.0",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"sweetalert2": "^10.15.5",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "run-p watch:css start:react",
"start:react": "react-scripts start",
"build": "npm run build:css && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"build:css": "postcss src/assets/css/tailwind.css -o src/assets/css/main.css",
"watch:css": "postcss -w src/assets/css/tailwind.css -o src/assets/css/main.css"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"autoprefixer": "^10.2.5",
"eslint-plugin-react": "^7.21.5",
"npm-run-all": "^4.1.5",
"redux-devtools-extension": "^2.13.8",
"tailwindcss": "^2.1.2"
},
"optionalDependencies": {
"fsevents": "^2.3.2"
}
}
postcss.config.js
const tailwindcss = require('tailwindcss');
module.exports = {
plugins: [
require('postcss-import'),
tailwindcss('./tailwind.config.js'),
require('postcss-nested')({
"bubble": [
"screen"
]
}),
require('autoprefixer'),
],
};
tailwind.css
@tailwind base;
@tailwind components;
:root {
--p: 196 100% 46%;
--pf: 196 98% 40%;
--pc: 0 0% 100%;
--s: 15 98% 54%;
--sf: 15 84% 44%;
--sc: 0 0% 100%;
--a: 190 100% 26%;
--af: 190 100% 17%;
--ac: 0 0% 100%;
--n: 210 14% 32%;
--nf: 210 12% 21%;
--nc: 0 0% 100%;
--b1: 0 0% 100%;
--b2: 210 16% 95%;
--b3: 206 9% 84%;
--bc: 210 14% 32%;
--in: 196 90% 32%;
--su: 196 100% 46%;
--wa: 39 100% 50%;
--er: 0 78% 63%;
--rounded-box: 1rem; /* border-radius for cards and other big elements */
--rounded-btn: 0.5rem; /* border-radius for buttons and similar elements */
--rounded-badge: 9999px; /* border-radius for badge and other small elements */
--animation-btn: 0.25s; /* bounce animation time for button */
--animation-input: .4s; /* bounce animation time for checkbox, toggle, etc */
--padding-card: 2rem; /* default card-body padding */
--btn-text-case: uppercase; /* default text case for buttons */
--navbar-padding: .5rem; /* default padding for navbar */
--border-btn: 1px; /* default border size for button */
--focus-ring: 2px; /* focus ring size for button and inputs */
--focus-ring-offset: 2px; /* focus ring offset size for button and inputs */
}
h1 {
@apply font-bold mt-0;
font-size: 22px;
font-family: 'Roboto Slab', serif;
}
h2 {
@apply font-normal mt-0;
font-size: 20px;
font-family: 'Roboto Slab', serif;
}
h3 {
@apply font-normal mt-0;
font-size: 18px;
font-family: 'Roboto Slab', serif;
}
h4 {
@apply font-medium mt-0;
font-size: 16px;
font-family: 'Roboto Slab', serif;
}
h5 {
@apply font-normal mt-0;
font-size: 14px;
font-family: 'Roboto Slab', serif;
}
h6 {
@apply font-normal mt-0;
font-size: 12px;
font-family: 'Roboto', serif;
}
p {
font-size: 14px;
font-family: 'Roboto', serif;
}
.bg-primary .badge {
color: hsl(var(--nc));
}
.header-layout-small {
@apply flex items-center justify-between w-full p-3 h-16 bg-primary text-primary-content;
}
.downshift-options {
@apply rounded-md input absolute z-10 left-0 right-0 top-16 shadow-lg
}
.downshift-options-focus {
@apply bg-gray-200
}
.downshift-options-selected {
@apply font-bold
}
.invalid-feedback {
@apply mt-1 text-xs text-red-500
}
.invalid-tooltip {
@apply absolute z-10 hidden w-4 font-normal leading-normal text-white rounded p-2 bg-red-700
}
.is-invalid {
@apply border border-red-500
}
.is-invalid:focus {
@apply border border-red-500 ring
}
.txt {
@apply text-base font-light leading-relaxed mt-0 mb-4
}
.txt-sm {
@apply font-normal leading-normal mt-0 mb-4
}
.txt-lg {
@apply text-lg font-light leading-relaxed mt-6 mb-4
}
.card {
@apply rounded-xl
}
.card.white {
@apply bg-white shadow-lg
}
.scrolling-wrapper {
@apply flex flex-nowrap overflow-x-auto
}
/* Hide scrollbar for IE, Edge and Firefox
scrollbar-width: none; /* Firefox */
/* Hide scrollbar for Chrome, Safari and Opera */
.scrolling-wrapper::-webkit-scrollbar {
display: none;
}
.scrolling-wrapper .card {
justify-content: center;
flex: 0 0 auto;
align-items: center;
display: flex;
flex-direction: column;
}
.slots-times {
height: calc(100vh - 348px);
}
@tailwind utilities;
Can I see this file please? because this is the file that is reported for syntax error:
./src/assets/css/main.css
I'm closing this issue because it's not a problem with DaisyUI, but I'd be happy to help about this if I can.
Also, here are some repos with similar packages that might help:
https://github.com/saadeghi/daisyui-starter
https://github.com/saadeghi/nextjs-daisyui-headlessui
well, this CSS looks fine. There isn't even an error in this file which means PostCSS is working fine.
I'm not sure... maybe a css loader (webpack, babel, etc...) is causing the issue.
Maybe some dependencies are not compatible with each other.
I tried to install the packages from your package.json and it wasn't successful:
Ufff, it's a much deeper error than I was thinking. Thanks for your help!
I could solve the issue starting with a fresh new project, installing Tailwind & Daisy (always checking if it can be build), adding my code and so... possitive side effect: I'm getting a smaller build package! Thanks @saadeghi for your help and congrat for Daisyui, it's a great tool !
@ajatib Good to hear ๐
Thanks!
We're having the same issue with Angular 12 + Angular Material Design + Ionic Framework + Tailwind (added through ng add ngx-tailwind).
We get almost the same error:
[ng] ModuleBuildError: Module build failed (from ./node_modules/@angular-devkit/build-angular/node_modules/postcss-loader/dist/cjs.js):
[ng] ParserError: Syntax Error at line: 1, column 26
although there's an error higher up:
Unknown error from PostCSS plugin. Your current PostCSS version is 8.3.5, but postcss-preset-env uses 7.0.36. Perhaps this is the source of the error below.
The problem is that @angular-devkit/build-angular
depends on PostCSS version 8.3.5 and postcss-preset-env 7.0.36 which seems to cause the issue.
We don't have any postcss.config.js
file since we're on Angular 12 and it shouldn't be needed (Tailwind CSS works fine without Daisyui).
Anyone knows how to fix this?
I'm having this error trying to build a React app to deploy:
Using this package.json:
My project was working perfectly before I add Daisyui and postcss 8 Any idea?