Related
I am using a admin template on one of my laravel project and here are the files:
tailwind.config.js
const colors = require("tailwindcss/colors");
const {
toRGB,
withOpacityValue,
} = require("#left4code/tw-starter/dist/js/tailwind-config-helper");
module.exports = {
mode: "jit",
content: [
"./resources/**/*.blade.php",
"./resources/**/*.js",
"./resources/**/*.jsx",
"./resources/**/*.vue",
],
theme: {
extend: {
colors: {
rgb: toRGB(colors),
primary: withOpacityValue("--color-primary"),
secondary: withOpacityValue("--color-secondary"),
success: withOpacityValue("--color-success"),
info: withOpacityValue("--color-info"),
warning: withOpacityValue("--color-warning"),
pending: withOpacityValue("--color-pending"),
danger: withOpacityValue("--color-danger"),
light: withOpacityValue("--color-light"),
dark: withOpacityValue("--color-dark"),
slate: {
50: withOpacityValue("--color-slate-50"),
100: withOpacityValue("--color-slate-100"),
200: withOpacityValue("--color-slate-200"),
300: withOpacityValue("--color-slate-300"),
400: withOpacityValue("--color-slate-400"),
500: withOpacityValue("--color-slate-500"),
600: withOpacityValue("--color-slate-600"),
700: withOpacityValue("--color-slate-700"),
800: withOpacityValue("--color-slate-800"),
900: withOpacityValue("--color-slate-900"),
},
darkmode: {
50: withOpacityValue("--color-darkmode-50"),
100: withOpacityValue("--color-darkmode-100"),
200: withOpacityValue("--color-darkmode-200"),
300: withOpacityValue("--color-darkmode-300"),
400: withOpacityValue("--color-darkmode-400"),
500: withOpacityValue("--color-darkmode-500"),
600: withOpacityValue("--color-darkmode-600"),
700: withOpacityValue("--color-darkmode-700"),
800: withOpacityValue("--color-darkmode-800"),
900: withOpacityValue("--color-darkmode-900"),
},
},
fontFamily: {
roboto: ["Roboto"],
},
container: {
center: true,
},
maxWidth: {
"1/4": "25%",
"1/2": "50%",
"3/4": "75%",
},
strokeWidth: {
0.5: 0.5,
1.5: 1.5,
2.5: 2.5,
},
},
},
plugins: [require("#tailwindcss/forms")],
variants: {
extend: {
boxShadow: ["dark"],
},
},
}
and this, is my current webpack.mix.js
const mix = require('laravel-mix');
mix.js('resources/admin-template/js/app.js', 'public/assets/js/admin-template.js')
.js('resources/js/app.js', 'public/assets/js')
.react()
.sass('resources/sass/app.scss', 'public/assets/css')
.postCss("resources/admin-template/css/app.css", "public/assets/css/admin-template.css");
and here is my current postcss.config.js
module.exports = {
plugins: [
require("postcss-import"),
require("postcss-advanced-variables"),
require("tailwindcss/nesting"),
require("tailwindcss")("./tailwind.config.js"),
require("autoprefixer"),
],
};
Now, I had separately created frontend design, and it has this tailwind.config.js
module.exports = {
content: ['./*.html'],
theme: {
extend: {
colors: {
'primary': '#1A1C29',
'primary-light': '#2A2D3E',
'theme-blue': '#2563eb',
'theme-green': '#06D594',
'light-gray': '#999ba6',
'yellow': '#FFFF00',
'gold': '#facc15',
'red': '#FF0000'
},
fontFamily:{
'poppins': ['Poppins', 'sans-serif'],
'roboto' : ['Roboto', 'sans-serif']
},
fontSize:{
'xxs': '.63rem',
},
screens:{
'sm': '575px',
},
},
},
}
Now, I have this css on resources/css/front.css, now how could I compile on this laravel project by using this second tailwind config value for front .css only.
I have tried this by adding this line on webpack. But, its not compiling correctly, its using different colors combination.
.postCss("resources/css/front.css", "public/assets/css/front.css");
What would be the best and safest to handle this scenario with single tailwind.config.js
If merging both tailwind.config.js files is not an option, calling mix.postCss twice is one way to do it.
The postCss method accepts an array of PostCSS plugins. This allows you to pass tailwindcss with a different configuration file.
webpack.mix.js
const mix = require('laravel-mix');
mix.postCss('resources/css/app.css', 'public/css', [
require('tailwindcss')('tailwind.config.js')
]);
mix.postCss('resources/css/front.css', 'public/css', [
require('tailwindcss)('tailwind-front.config.js')
]);
In that case I'd suggest removing the postcss.config.js file from your project and providing the array of plugins manually for each calls to postCss.
webpack.mix.js
const mix = require('laravel-mix');
mix.postCss('resources/css/app.css', 'public/css', [
require("postcss-import"),
require("postcss-advanced-variables"),
require("tailwindcss/nesting"),
require('tailwindcss')('tailwind.config.js'),
require("autoprefixer"),
]);
mix.postCss('resources/css/front.css', 'public/css', [
require("postcss-import"),
require("postcss-advanced-variables"),
require("tailwindcss/nesting"),
require('tailwindcss')('tailwind-front.config.js'),
require("autoprefixer"),
]);
Trying to figure out how to use a color variable from a SCSS file I keep getting an error:
ERROR #98123 WEBPACK
Generating development JavaScript bundle failed
Invalid options object. Sass Loader has been initialized using an
options object that does not match the API schema.
options has an unknown property 'data'. These properties are valid: object { implementation?, sassOptions?, additionalData?, sourceMap?,
webpackImporter? }
File: src/styles/main.scss
I've followed the Gatsby docs and I've installed gatsby-plugin-sass and added it to gatsby-config.js:
{
resolve: `gatsby-plugin-sass`,
options: {
data: `#import "${__dirname}/src/styles/main.scss";`,
},
},
I've added the following to gatsby-browser.js:
// SCSS
import './src/styles/main.scss'
I've tried to bring it in my component:
import React from 'react'
import PropTypes from 'prop-types'
// Material UI
import { AppBar, Toolbar, makeStyles } from '#material-ui/core'
// Components
import Logo from './logo'
import Navigation from './navigation'
const useStyles = makeStyles(() => ({
toolbar: {
background: $FooBar,
display: 'flex',
justifyContent: 'flex-end',
},
navigation: {
display: 'flex',
},
}))
const Header = ({ title, menu }) => {
const { toolbar, navigation } = useStyles()
return (
<>
<AppBar>
<Toolbar className={toolbar}>
<Logo name={title} />
<Navigation className={navigation} menu={menu} />
</Toolbar>
</AppBar>
</>
)
}
Header.propTypes = {
siteTitle: PropTypes.string,
}
Header.defaultProps = {
siteTitle: ``,
}
export default Header
and I tried to import it directly into the component with:
import '../styles/main.scss'
Research
Include sass in gatsby globally:
{
resolve: `gatsby-plugin-sass`,
options: {
data: `#use "${__dirname}/src/styles/main.scss";`,
},
},
import style from '../styles/main.scss'
const useStyles = makeStyles(() => ({
toolbar: {
background: style.FooBar,
display: 'flex',
justifyContent: 'flex-end',
},
navigation: {
display: 'flex',
},
}))
Import sass variables to gatsby component
Gatsby Build Breaks SCSS Export Variables
How to include SCSS Glob in a Gatsby project?
Gatsby fails after using Sass files with '#use 'sass:color'
import style from '../styles/main.scss'
const useStyles = makeStyles(() => ({
toolbar: {
background: style.FooBar,
display: 'flex',
justifyContent: 'flex-end',
},
navigation: {
display: 'flex',
},
}))
{
resolve: `gatsby-plugin-sass`,
options: {
implementation: require('sass'),
},
},
I do not get a build error in the terminal but the background color passed to the component doesn't show up.
In a Gatsby site with Material UI how do I bring in a SCSS color variable to use within a component?
Broken down basic variation of what I've tried to do:
Have you tried changing this:
{
resolve: `gatsby-plugin-sass`,
options: {
data: `#import "${__dirname}/src/styles/main.scss";`,
},
},
To this:
{
resolve: 'gatsby-plugin-sass',
sassOptions: {
data: `#import "${__dirname}/src/styles/main.scss";`,
},
},
It seems that node-sass has some deprecated dependencies, so alternatively to this workaround, you can try upgrading your plugin package to the 3.0.0 version.
I'm using Laravel Mix and PostCSS to build Tailwind.
Everything works, I can even Purge unused styles.
I have strange outputs when I build (a LOT of these) :
--tw-space-y-reverse [
{
index: 40,
token: '-',
type: 9,
eval: [Function: sub],
precedence: 1,
show: '-'
},
{
index: 40,
token: '-',
type: 9,
eval: [Function: sub],
precedence: 1,
show: '-'
}
]
I'm using the latest TailwindCSS version.
Here is the relevant part of my webpack.mix.js :
const mix = require('laravel-mix');
require('laravel-mix-purgecss');
let tailwindcss = require('tailwindcss');
mix.postCss('resources/css/tailwind.css', 'public/css/soumettre202101.css', [
tailwindcss('./tailwind.config.js'),
]);
I don't even know where to start. I don't know what's causing this.
Any lead will be appreciated!
I can remove the output by disabling this core plugins (in my tailwind.config.js) :
module.exports = {
corePlugins: {
space: false,
ringWidth: false,
ringColor: false,
ringOffsetWidth: false,
ringOffsetColor: false,
ringOpacity: false,
divideOpacity: false,
divideColor: false,
divideWidth: false,
}
}
Even more strange : if I only disable "space", the output changes from the one above to the same thing but with --tw-ring-width-reverse, as if the last plugin used produces the output...
I'm not sure if that helps, but I will show you my config that seems to be working fine (using Sass), I removed some irrelevant parts.
webpack.mix.js
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
mix.sass('resources/sass/tailwind.scss', 'public/css')
.options({
processCssUrls: false,
postCss: [ tailwindcss('./resources/tailwind.config.js') ],
})
.version();
tailwind.scss
#import "~tailwindcss/base";
#import "~tailwindcss/components";
#import "~tailwindcss/utilities";
and finally tailwind.config.js
const defaultTheme = require('tailwindcss/defaultTheme');
const colors = require('tailwindcss/colors');
module.exports = {
purge: {
content: [
'./resources/views/**/*.blade.php',
'./resources/js/**/*.js',
],
defaultExtractor: content => content.match(/[\w-/.:]+(?<!:)/g) || []
},
theme: {
extend: {
fontFamily: {
sans: ['Inter var', ...defaultTheme.fontFamily.sans],
},
colors: {
// some custom colors
gray: colors.trueGray,
indigo: colors.indigo,
red: colors.rose,
yellow: colors.amber,
bluegray: colors.blueGray,
orange: colors.amber,
teal: colors.teal,
pink: colors.pink,
green: colors.green,
},
},
},
variants: {
gridColumn: ['responsive', 'hover'],
gridColumnStart: ['responsive', 'hover'],
gridColumnEnd: ['responsive', 'hover'],
},
plugins: [
require('tailwindcss'),
require('autoprefixer'),
require('#tailwindcss/forms'),
require('#tailwindcss/typography'),
require('#tailwindcss/aspect-ratio'),
],
};
When I run nom run dev everything seems to be fine, there is no output like you showed but I have things like this:
.space-y-11 > :not([hidden]) ~ :not([hidden]){
--tw-space-y-reverse: 0;
margin-top: calc(2.75rem * calc(1 - var(--tw-space-y-reverse)));
margin-bottom: calc(2.75rem * var(--tw-space-y-reverse));
}
Obviously later only those that are really used in blade/js files are in final file when I run npm run prod
The problem has been solved by ugrapding Laravel Mix to the latest version.
I installed Tailwind using a tutorial and tried working around with a custom tailwind config file, but when I try to add first, last, or group pseudo-classes, it doesn't affect the CSS. I also previously noticed this with inset, and I added the inset section manually. Am I missing anything in config or Mix?
Tailwind config file
const { rotate } = require('tailwindcss/defaultTheme');
const defaultTheme = require('tailwindcss/defaultTheme');
module.exports = {
purge: [
'./vendor/laravel/jetstream/**/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
],
purge: [],
darkMode: false, // or 'media' or 'class'
theme: {
cursor: {
'none': 'none'
},
opacity: {
'0': '0',
'25': '.25',
'50': '.5',
'75': '.75',
'10': '.1',
'20': '.2',
'30': '.3',
'40': '.4',
'50': '.5',
'60': '.6',
'70': '.7',
'80': '.8',
'90': '.9',
'100': '1',
},
zIndex: {
'-1' : -1,
'0': 0,
'10': 10,
'20': 20,
'30': 30,
'40': 40,
'50': 50,
'25': 25,
'50': 50,
'75': 75,
'100': 100,
'auto': 'auto',
},
inset: (theme, { negative }) => ({
auto: 'auto',
...theme('spacing'),
...negative(theme('spacing')),
'1/2': '50%',
'1/3': '33.333333%',
'2/3': '66.666667%',
'1/4': '25%',
'2/4': '50%',
'3/4': '75%',
full: '100%',
'-1/2': '-50%',
'-1/3': '-33.333333%',
'-2/3': '-66.666667%',
'-1/4': '-25%',
'-2/4': '-50%',
'-3/4': '-75%',
'-full': '-100%',
}),
colors: {
white:'#ffffff',
gray: {
100: "#D2D2D2",
200: "#BCBCBC",
300: "#A5A5A5",
400: "#8F8F8F",
500: "#797979",
600: "#626262",
700: "#4C4C4C",
800: "#353535",
900: "#1F1F1F",
},
orange: {
100: "#FFDFCC",
200: "#FFCFB3",
300: "#FFBF99",
400: "#FFB080",
500: "#FFA066",
600: "#FF904D",
700: "#FF8033",
800: "#FF701A",
900: "#FF6000",
},
},
rotate:{
'-180': '-180deg',
'-90': '-90deg',
'-45': '-45deg',
'0': '0',
'45': '45deg',
'90': '90deg',
'135': '135deg',
'180': '180deg',
'270': '270deg',
'360': '360deg'
},
borderWidth: {
DEFAULT: '1px',
'0': '0',
'2': '2px',
'3': '3px',
'4': '4px',
'6': '6px',
'8': '8px',
'10': '10px',
'12': '12px',
'14': '14px',
'16': '16px'
},
extend: {
height:{
'5.5/6': '91.6667%'
},
fontFamily: {
sans: ['Arial', ...defaultTheme.fontFamily.sans],
},
transitionDuration: {
'2000': '2000ms',
'3000' : '3000ms',
},
transitionProperty: {
'top': 'top',
'left': 'left',
},
lineHeight:{
12 : '3rem',
13: '3.25rem',
14: '3.5rem'
},
},
},
variants: (theme) => ({
...theme('variants'),
padding: ['first','last'],
margin: ['first','last'],
backgroundColor: ['first'],
textColor: ['first'],
outline: ['active','focus'],
position: ['first','last'],
opacity: ['responsive', 'hover', 'focus', 'disabled'],
borderRadius: ['hover', 'focus'],
width:['group-hover']
}),
plugins: [
require('#tailwindcss/ui'),
],
};
Laravel Mix File
const mix = require('laravel-mix');
const atImport = require('postcss-import');
const tailwindcss = require('tailwindcss');
mix.browserSync('localhost:8000');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel applications. By default, we are compiling the CSS
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js')
.js('resources/js/admin.js','public/js')
.sass('resources/scss/app.scss', 'public/css')
.sass('resources/scss/admin.scss','public/css')
.options({
processCssUrls: false,
postCss: [
atImport(),
tailwindcss('./tailwind.config.js')
],
})
.webpackConfig(require('./webpack.config'));
I am not an expert in this but have used Tailwind CSS from pre V1. I notice that you are trying to use features from V2, (eg darkmode).
Several issues:
purge: [
'./vendor/laravel/jetstream/**/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
],
purge: [],
does the second purge: [ ] clear the first array?
My tailwind.config.js file does not have the first 2 lines ending with require('tailwindcss/defaultTheme');
I have no idea what these are referencing, but do you not have your source folders for js included in the purge list. Add this line to the purge list if your javascript adds classes
.resources/js/**/*.js
As for the webpack.mix.js file my last lines are
.options({
processCssUrls: false,
postCss: [ tailwindcss('./tailwind.config.js') ],
});
Sorry but I am not an expert
I am trying to integrate CKEditor5 in my Aurelia Application but no sucess.I tried many guides but getting no success.I tried CKEditor official guides too like as
https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/advanced-setup.html
https://ckeditor.com/docs/ckeditor5/latest/framework/guides/overview.html
App.ts
import ClassicEditor from '#ckeditor/ckeditor5-editor-classic/src/classiceditor';
import Essentials from '#ckeditor/ckeditor5-essentials/src/essentials';
import Paragraph from '#ckeditor/ckeditor5-paragraph/src/paragraph';
import Bold from '#ckeditor/ckeditor5-basic-styles/src/bold';
import Italic from '#ckeditor/ckeditor5-basic-styles/src/italic';
export class App {
constructor(){
ClassicEditor
.create( document.querySelector( '#editor' ), {
plugins: [ Essentials, Paragraph, Bold, Italic ],
toolbar: [ 'bold', 'italic' ]
} )
.then( editor => {
console.log( "Editor Initialized",editor );
} )
.catch( error => {
console.error( error.stack );
} );
}
}
app.html
<template>
<h1>${message}</h1>
<div >
<textarea name="editor" id="editor" cols="39" rows="21"></textarea>
</div>
</template>
WebPack.config
By official guide of CKEditor about webpack i was getting errors of loaders after some search i found a helo on github and did some modification in code like as
rules: [
{
// Or /ckeditor5-[^/]+\/theme\/icons\/.+\.svg$/ if you want to limit this loader
// to CKEditor 5 icons only.
test: /ckeditor5-[^/]+\/theme\/icons\/[^/]+\.svg$/,
use: [ 'raw-loader' ]
},
{
// Or /ckeditor5-[^/]+\/theme\/[\w-/]+\.css$/ if you want to limit this loader
// to CKEditor 5 theme only.
test: /ckeditor5-[^/]+\/theme\/[\w-/]+\.css$/,
use: [
{
loader: 'style-loader',
options: {
injectType: 'singletonStyleTag'
}
},
{
loader: 'postcss-loader',
options: styles.getPostCssConfig( {
themeImporter: {
themePath: require.resolve( '#ckeditor/ckeditor5-theme-lark' )
},
minify: true
} )
},
]
},
// CSS required in JS/TS files should use the style-loader that auto-injects it into the website
// only when the issuer is a .js/.ts file, so the loaders are not applied inside html templates
{
test: /\.css$/i,
issuer: [{ not: [{ test: /\.html$/i }] }],
use: extractCss ? [{
loader: MiniCssExtractPlugin.loader
},
'css-loader'
] : ['style-loader', ...cssRules]
},
{
test: /\.css$/i,
issuer: [{ test: /\.html$/i }],
// CSS required in templates cannot be extracted safely
// because Aurelia would try to require it again in runtime
use: cssRules
},
{ test: /\.html$/i, loader: 'html-loader' },
{ test: /\.ts$/, loader: "ts-loader", options: { reportFiles: [ srcDir+'/**/*.ts'] }, include: karma ? [srcDir, testDir] : srcDir },
// embed small images and fonts as Data Urls and larger ones as files:
{ test: /\.(png|gif|jpg|cur)$/i, loader: 'url-loader', options: { limit: 8192 } },
{ test: /\.woff2(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff2' } },
{ test: /\.woff(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'url-loader', options: { limit: 10000, mimetype: 'application/font-woff' } },
// load these fonts normally, as files:
{ test: /\.(ttf|eot|svg|otf)(\?v=[0-9]\.[0-9]\.[0-9])?$/i, loader: 'file-loader' },
...when(coverage, {
test: /\.[jt]s$/i, loader: 'istanbul-instrumenter-loader',
include: srcDir, exclude: [/\.(spec|test)\.[jt]s$/i],
enforce: 'post', options: { esModules: true },
})
]
},
Now in console getting no error and CKEditor classes are also showing when inspecting DIV editor class but on View HTML showing no editor and seeing blank page.Kindly do help about this.
Your ckeditor create code cannot be in constructor.
The constructor of app runs before the dom was created, so it could not find '#editor'.
Move your editor create code to attached() callback.
attached() {
ClassicEditor.create...
}