Everytime I update .js code in my Ember App (components, tests, etc.) my app.css file is rebuilt, even though I'm not touching any CSS!
I am using PostCSS and TailwindCSS plugin. Every time I save a .js the entire TailwindCSS library is rebuilt and takes 1200-2000ms. This is really unnecessary and I would like to know how to avoid it. If I disable TailwindCSS the rebuild time of PostCSS drops to 191ms on every .js save.
There are a few solution ideas I'd like to explore:
Is it possible to configure Ember rebuild my CSS ONLY when I change
CSS?
Is it possible to configure PostCSS to rebuild only when CSS has
changed?
How can I configure TailwindCSS to use a static CSS file for the library, and then setup
PostCSS to build only my custom tailwind classes using the
tailwind plugin?
ember-cli-build.js
postcssOptions: {
compile: {
plugins: [
{
module: require("postcss-import"),
options: {
path: ["node_modules"]
}
},
require("tailwindcss")("./config/tailwind.config.js")
]
}
}
config/tailwind.config.js
module.exports = {
theme: {
extend: {
height: {
"80": "20rem",
"screen-80": "80vh",
"screen-60": "60vh"
},
minWidth: {
"96": "24rem",
screen: "100vw"
},
maxWidth: {
"min-content": "min-content",
screen: "100vw"
},
screens: {
xxl: "1920px"
},
zIndex: {
"9999": 9999
},
colors: {
puke: {
100: "#fff5f7",
200: "#fed7e2",
300: "#fbb6ce",
400: "#f687b3",
500: "#ed64a6",
600: "#d53f8c",
700: "#b83280",
800: "#97266d",
900: "#702459"
}
},
backgroundColor: theme => theme("colors"),
textColor: theme => theme("colors"),
borderColor: theme => ({
...theme("colors"),
default: theme("colors.gray.300", "currentColor")
})
}
},
variants: {},
plugins: []
};
Related
I am using react-toolbox and react-css-themr to supply theme. I create my contextTheme and supply it through ThemeProvider. Everything's seems fine. I am using webpack, the styles are exported and loaded in the attribute of my page, so there is no problem with the importing the css.
EDIT: I can clearly see the context theme is loaded to the website, as I can observe RT objects
my contextTheme file looks like this and is named contextTheme.js
export default {
RTAutocomplete: require('./assets/style/themes/autocomplete.module.css'),
RTButton: require('./assets/style/themes/button.module.css')
};
I can see custom theme in tag like this
.autocomplete-module--autocomplete--tESXbPMw {
padding: 0
}
.autocomplete-module--autocomplete--tESXbPMw .autocomplete-module--suggestions--t6ziL7OQ {
background-color: red;
border-color: blue;
border-radius: 0
}
theme provider looks like this
<ThemeProvider theme={contextTheme}>
<Router store={s} history={h}>
{ routes }
</Router>
</ThemeProvider>
resulting html element still has only default style applied, because no style is attached to it.
In case my webpack css config looks like this. I am not sure if that is relevant, but just in case.
{
test: /\.scss|\.css$/i,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 1,
modules: {
exportGlobals: true,
mode: "local",
auto: undefined,
localIdentName: "[name]--[local]--[hash:base64:8]",
},
sourceMap: shouldUseSourceMap,
}
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [
[
"postcss-preset-env",
{
// Options
},
],
],
},
},
},
],
sideEffects: true,
},
This is the import url
After writing npm run build-css on the terminal. The changes i made before and the change i wanted to make disappeared. None of the tailwindcss styles i had in my index.html was found.
extend: {
colors: {
primary: "FF6363"
},
fontfamily: {
body: ['Nunito'],
}
},
I would start by making sure the color-extend has the correct '#' before it and also wrapping the color name in quotes also.
Also check your webpack.mix.js file to make sure yourt calling the files in the correct order.
Should resemble something similar to mine.
mix.js("resources/js/app.js", "public/js")
.vue()
.sass("resources/sass/app.scss", "public/css")
.sass("resources/sass/components/sidebar.scss", "public/css")
.sass("resources/sass/components/modal.scss", "public/css")
.sass("resources/sass/components/language-picker.scss", "public/css")
.sass("resources/sass/custom.scss", "public/css")
.options({
processCssUrls: false,
postCss: [tailwindcss("tailwind.config.js")],
output: {
path: "birdboard",
publicPath: "/dist/js/",
filename: "./dist/js/bundle.js"
}
});
Also check your tailwind.config.js file for formatting issues, my version follows this simple layout.
module.exports = {
theme: {
screens: {
sm: "576px",
// => #media (min-width: 576px) { ... }
md: "960px",
// => #media (min-width: 960px) { ... }
lg: "1440px"
// => #media (min-width: 1440px) { ... }
},
backgroundColor: theme => ({
page: "var(--page-background-color)",
card: "var(--card-background-color)",
button: "var(--button-background-color)",
header: "var(--header-background-color)"
}),
colors: {
error: "var(--text-error-color)",
grey: {
default: "rgba(0, 0, 0, 0.4)",
lighter: "#F5F6F9"
},
white: {
default: "#fff"
},
blue: {
default: "#47cdff",
light: "#8ae2fe"
},
default: "var(--text-default-color)",
accent: {
default: "var(--user-accent-color)",
light: "var(--text-accent)"
},
muted: {
default: "var(--text-muted-color)",
light: "var(--text-muted-light-color)"
}
},
boxShadow: {
default: "0 0 5px 0 rgba(0, 0, 0, 0.08)",
blue: "0 2px 7px 0 #b0eaff"
},
extend: {}
},
variants: {},
plugins: []
};
Just as a quick note. You could try 'bg-rose-500' which is very similar to the color you was trying to add.
I use 'npm run dev' to build my assets in Laravel & Tailwind
This is for one-off colours using TailwindCSS
Arbitrary values
If you need a one-off custom color in your project, consider using Tailwind’s arbitrary value notation to generate a class for that color on-demand instead of adding it to your theme:
<button class="bg-[#1da1f2] text-white ...">
<svg><!-- ... --></svg>
Share on Twitter
</button>
I'm pretty lost. Trying to deploy my Remix Tailwind App which is working perfectly in Dev Environment.
Dev Environment working fine
As soon as I deploy, almost anything is gone basically. See here:
Vercel Env not working
Here's my tailwind config file:
content: ["./app/**/*.{ts,tsx,jsx,js}"],
module: {
rules: [
{
test: /\.css$/i,
use: ["style-loader", "css-loader"]
}
]
},
safelist: [{ pattern: /.*/ }],
theme: {
screens: {
xxs: "350px",
custom3: "420px",
xs: "480px",
custom2: "580px",
sm: "676px",
md: "768px",
custom: "910px",
lg: "1050px", // laptop: Default screen size
xl: "1280px", //desktop
"2xl": "1526px",
"3xl": "1696px"
},
extend: {
colors: {
textLgColor: "var(--text-large-color)",
textSmColor: "var(--text-small-color)",
subText: "var(--sub-text-color)",
navBar: {
linkActive: "var(--nav-link-active)",
linkActiveStripe: "var(--nav-link-active-stripe)"
},
mobileNav: {
text: "var(--mobile-text)",
textHover: "var(--mobile-hover-text)",
border: "var(--mobile-border)"
},
aboutMe: {
smIconBg: "var(--sm-icon-bg)",
aboutMeText: "var(--aboutme-text)",
alissa: "var(--alissa)"
},
projects: {
text: "var(--project-text-color)",
subText: "var(--project-sub-text)",
arrow: "var(--project-arrow)",
recentBg: "var(--recent-project-bg)",
recentHover: "var(--recent-project-bg-hover)",
recentShadow: "var(--recent-project-shadow)"
},
contact: {
label: "var(--label-text)",
send: "var(--send-btn)",
sendHover: "var(--send-btn-hover)"
},
blog: {
lgText: "var(--blog-lg-text)",
border: "var(--blog-input-border)",
tagBg: "var(--tag-btn-bg)"
},
post: {
bodyText: "var(--text-body)",
bodyTextLg: "var(--text-body-lg)",
icon: "var(--icon)",
iconHover: "var(--icon-hover)",
hyperlink: "var(--hyperlink)",
hyperlinkHover: "var(--hyperlink-hover)",
quote: "var(--quote)",
quoteAuthor: "var(--quote-author)"
}
}
}
},
plugins: [require("#tailwindcss/line-clamp")]
};
As this point I'm so frustrated, idgaf about my codebase anymore so here you go, I just made the repo public: https://github.com/flo-s99/Devato/settings
Any help appreciated
It's my tailwind configuration file here I tried to add a new colour variable. But it's not working!!!
But in the VsCode Tailwind CSS IntelliSense plugin suggest the colour.
tailwind.config.cjs
module.exports = {
mode: 'jit',
purge: ["./src/**/*.svelte"],
darkMode: false, // or 'media' or 'class'
theme: {
colors: {
'test-blue': {
100: '#d0e7fb',
DEFAULT: '#0063bd',
500: '#4299e1',
700: '#2b6cb0',
}
},
},
variants: {
extend: {},
},
plugins: [],
}
VsCode Snippet
In Web
note: After change the config file, I restart the hmr.
In order to have the user be able to select their color scheme in my website, I added a few themes in my style.css file. For example, one is "theme-light"
.theme-light {
--color-bg-primary: theme('colors.white');
--color-bg-typing: theme('colors.white');
--color-bg-input: theme('colors.white');
--color-bg-redo: theme('colors.blue.500');
--color-bg-redo-hover: theme('colors.red.500');
--color-bg-nav: theme('colors.red.500');
--color-bg-nav-active: theme('colors.red.500');
--color-text-primary: theme('colors.gray.900');
--color-text-secondary: theme('colors.gray.600');
--color-text-current: theme('colors.gray.900');
--color-text-correct: theme('colors.green.400');
--color-text-wrong: theme('colors.red.400');
--color-text-stats: theme('colors.gray.600');
--color-placeholder-primary: theme('colors.gray.600');
}
And I edited my tailwind.config.js file like so:
module.exports = {
future: {
removeDeprecatedGapUtilities: true,
purgeLayersByDefault: true,
},
purge: [],
theme: {
backgroundColor: {
primary: 'var(--color-bg-primary)',
typing: 'var(--color-bg-typing)',
input: 'var(--color-bg-input)',
redo: 'var(--color-bg-redo)',
'redo-hover': 'var(--color-bg-redo-hover)',
nav: 'var(--color-bg-nav)',
'nav-active': 'var(--color-bg-nav-active)',
},
textColor: {
primary: 'var(--color-text-primary)',
secondary: 'var(--color-text-secondary)',
current: 'var(--color-text-current)',
correct: 'var(--color-text-correct)',
wrong: 'var(--color-text-wrong)',
stats: 'var(--color-text-stats)',
},
placeholderColor: {
primary: 'var(--color-placeholder-primary)',
},
},
variants: {},
plugins: [require('#tailwindcss/typography')],
};
My question is: now I am unable to set anything like I was before in the html (like "text-blue-400" or "text-opacity-50"). How can I get the default configurations working again?
oh lol. all i had to use extend: https://tailwindcss.com/docs/theme