Laravel Tailwind CSS - generate all classes depends on ENV - css

I just jump to laravel 9 recently (from few months ago), kinda wondering about,
Is it possible to generate all css classes (including custom classes), BUT, only when APP_ENV on .env is not production?
I tried to overcome No.1 (see below explanation), by using const APP_ENV = import.meta.env.VITE_APP_ENV; on tailwind.config.js - so I can do if - else thing, to load things, but it produce an error - offset is longer than source length! offset 81 > length 59. Is it possible to get .env variables on tailwind.config.js?
As I tried to find another way for No.2. I'm narrowing my objective on No.1 and No.2, so, I tried to load all possibilities of my "custom classes" only on dev. By using safelist - to generate all my-own custom class, but it seems not working well, since, the custom class that I want to add doesn't added. I'm using this - pattern: /./ - since I saw this article says so (please, correct me if I'm wrong), but, it's indeed "hitting" all other classes, not just my custom classes. I want to add all of my "custom css class" without adding the variants one-by-one. Maybe something like variants: *? (I already check around on tailwind docs, but couldn't found something like that)
I tried a proper way, to just load all my custom classes like pattern: /ctm/, but as stated on tailwind documentation
Patterns can only match against base utility names like /bg-red-.+/, and won’t match if the pattern includes a variant modifier like /hover:bg-red-.+/.
How can I do so, without me typing & guessing all of the possibility of variants?
Explanation how I try to overcome For question No.1 -
I tried using these code on app.js
const APP_ENV = import.meta.env.VITE_APP_ENV;
if (APP_ENV == 'production') {
//need to use ()
import ('../css/app.css');
}
and with below code on app.blade.php
#if (config('app.env') != 'production')
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp"></script>
#endif
But, when it comes to a custom classes on tailwind.config.js - for example
theme: {
extend: {
fontFamily: {
sans: ['Nunito', ...defaultTheme.fontFamily.sans],
},
colors: {
'ctm-dark-purple': '#2a234f', //<--- custom class here
'ctm-light-dark-purple': '#2a234f', //<--- custom class here
},
},
},
It doesn't generate that custom classes, since I "block" the generated class and swap it into cdn mode on dev.
So, in-summary, how can I "generate all css classes" only on "development" mode? Along with my "custom css class"? If that's not possible, then, is it possible to overcome No.3? I want to add all of my "custom css class" without adding the variants one-by-one. Maybe something like variants: *?
My main reason is simply, I want to apply classes directly on web-browser console and see the changes more faster, rather than back-and-forth modifying-then-save the code on text-editor.
Thanks a lot!
Log -
Updating Problem No.3 - since forgot to mention precisely what I want

Related

VSCode not commenting css.liquid lines correctly

I've been having a problem when trying to comment out a line in a css.liquid file with the VScode shortcut (CTRL+/).
Whenever I do this it puts {%\s*# in front of the line and doesn't comment out the code. I tried disabling all extensions but it's not helping. I haven't touched any settings. When I switch to CSS or Liquid it will comment out fine, but Liquid CSS doesn't work.
Does anybody recognize this issue?
===== This ended up being a problem with the extension itself, it has since been fixed!
I see this issue has been reported lately: Incorrect comment blocks in Liquid files with this extension enabled.
I see this in the liquid css language configuration file:
"comments": {
"lineComment": "{%\\s*#",
"blockComment": [ "/*", "*/" ]
I don't know what the lineComment value is supposed to be but I have never seen a regex value there in other language configuration files - so it may be a mistake.
I built an extension which may be able to help until the language configuration file is fixed: Custom Language Properties.
Install it.
Run the command Custom Language Properies: Check for new language extensions.
Make this setting in your settings.json:
"custom-language-properties": {
"liquid-css.comments.lineComment": "",
}
If this doesn't work immediately, try a reload of vscode.
This basically sets the lineComment's to null and so the blockComment will be used instead. I am not familiar with Liquid comment styles so let me know if that is not how line comments are supposed to work. Demo:

How Can I turn in VSCode TailwindCSS Intellisense tips in dictionaries with specific names?

I store my Tailwind classes in reactapp in dictionaries:
const styles = {
wrapper: "overflow-hidden pb-8 bg-red-50"
...
}
I want to have Intellisense tips there, which by default - doesn't work here.
I found the solution in TailwindCSS Intellisense extension settings:
"tailwindCSS.classAttributes": [
""
]
The setting "" make that Intellisense tips show inside strings in my styles dictionary BUT they also appear in every other string in every other dictionary ;_;
Is it possible to set showing TailwindCss Intellisense tips only in dictionaries with specific names?
I found the answer right before i clicked "Post you question"
I don't believe it is that simple...
You can just put the name in the same option and it is working:
"tailwindCSS.classAttributes": [
"styles"
]
And now in every dictionary called styles I have Tailwind Intellisense tips, and i don't have them i other dictionaries. Awesome! :>

Emmet-Atom custom snippets not working as intended

As I am extremely new to programming I might just be overlooking some obvious issue so please bare with me.
I wanted to use custom snippets to extend the already existing ones to speed up my future workflow.
I created a snippets.json file, which contains this code
{
"html": {
"snippets": {
"page": "header>h1^main+footer{${0:©}}",
"a:link": "a[href='http://${0}']"
}
},
"css": {
"snippets": {}
}
}
when typing page, then pressing tab (or ctrl+e) in my HTML file, it doesn't output the Markdown, instead it just prints header>h1^main+footer{}
I put the a:link in there because it's a snippet that already exists within Emmet to test if the issue was with my custom snippets file.
And yes, the issue persists, instead of giving me the Markdown it only says a[href='http://']
Inside the Atom settings are 2 checkboxes:
Format Line Breaks
Use Emmet Comments
I have checked and unchecked both individually and together, nothing has resolved the Problem.
Settings inside of Atom

How to set type for special css-property's like variable . Typescript

I suppose there are already existing answers and I will thank you even if you just paste the link for the existing thread. But anyway.
There are in React when I specify style prop I have pretty good autocompletion and validation.
For example
What do I want?
I want to implement the same logic for my variable.
For example, in the code below
const position: ProperType = 'staticcc';
I want to replace ProperType with a really suitable type. After which
VScode will underline position and told me that there are errors (because 'staticcc' is an invalid value for CSS position property)
VScode will propose autocompletion like in the screenshot above.
I suppose there should be a special library or smth like this with predefined types. I even have googled csstype, it works fine for objects which I suppose to pass as style props. But I need not object, I need a special type for special CSS property to assign to the special variable. And don't know-how.
install csstype and
import * as CSS from 'csstype';
const position: CSS.Property.Position = 'static'

Add font_formats to ImpresspagesCMS tinyMCE

Trying to add custom font formats I cant seem to figure out how. I have been able to do other stuff with config files and created a few things already but this one isn't working whatsoever.
originalConfig.toolbar1 = originalConfig.toolbar1 + ' fontselect ';
originalConfig.font_formats = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;AkrutiKndPadmini=Akpdmi-n';
return originalConfig;
Even this way originalConfig.font_formats = originalConfig.font_formats + '';
however it is throwing the error
"Uncaught TypeError: Cannot read property 'indexOf' of undefined"
that is coming from the e.addButton("fontselect", function(){}); tinymce.min.js which handles the default font family formatter in TinyMCE which makes me believe that I am close to succeed. Somehow data is not being passed to the Index in order to populate the listbox containing the different fonts.
this would be fairly simple in TinyMCE but your override system isn't documented.
any help is appreciated.
There are two concepts in TinyMCE: fonts and styles. Not sure which one you are referring to. But in any case I would suggest to go with styles and here is how you can add your own styles: https://www.impresspages.org/docs/tinymce

Resources