Tailwindcss2 @apply directive doesn't work inside vue component
See original GitHub issue- Laravel Mix Version: “^6.0.6”
- Node Version: 14.4.0
- NPM Version: 6.14.5
- OS: windows
I create a laravel application with jetstream and inertia-vue stack for my new project problem is Tailwindcs version 2 using postCss
and it doesn’t support @apply
directive inside vue components but inside .css file it works fine I don’t want that because that css file will load my every page I just want short inline utility classes with @apply
directive but I can’t, How Can I achieve that.?
inside my vue template
<template>
<div class="mt-4">
<label for="hello">Hello</label>
<input id="hello" class="input"/>
</div>
</templete>
<style scoped>
.input {
@apply bg-gray-200 border h-10
}
</style>
output inside browser like this
webpack.mix.js
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js').vue()
.postCss('resources/css/app.css', 'public/css', [
require('postcss-import'),
require('tailwindcss'),
require('autoprefixer'),
])
.webpackConfig(require('./webpack.config'));
if (mix.inProduction()) {
mix.version();
}
webpack.config.js
const path = require('path');
module.exports = {
resolve: {
alias: {
'@': path.resolve('resources/js'),
},
},
};
tailwind version : “^2.0.1”,
laravel version : 8.x,
jetstream version : 2.x,
inertiajs version: “^0.8.2”
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:29 (1 by maintainers)
Top Results From Across the Web
Tailwindcss @apply directive doesn't work inside vue ...
A workaround that can temporarily solve this problem: . In webpack.config.js
Read more >Tailwindcss2 @apply directive doesn't work inside vue ...
I create a laravel application with jetstream and inertia-vue stack for my new project problem is Tailwindcs version 2 using postCss and it ......
Read more >Tailwindcss2 @apply directive doesn't work inside ... - Laracasts
I create a laravel application with jetstream and inertia-vue stack for my new project problem is Tailwindcs version 2 using postCss and it...
Read more >Using with Preprocessors - Tailwind CSS
A guide to using Tailwind with common CSS preprocessors like Sass, Less, and Stylus.
Read more >the `@apply` class does not exist. if `@apply` is a custom ...
However when I use that class inside apply directive in a component as seen above, ... Tailwind doesn't work inside the style in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A workaround that can temporarily solve this problem without using laravel-mix-tailwind:
In
webpack.mix.js
:In
webpack.config.js
:In
postcss.config.js
:Now I can use:
The solution on the fresh install is as simple as putting a bare config file on the root of the project. Source.