I am using Tailwind CSS in Laravel with VueJS component like this.
<template>
</template>
<script>
</script>
<style lang="postcss" scoped>
.day-disabled {
@apply text-gray-400;
}
</style>
However it is complaining that
Module parse failed: Unexpected token (685:0)
File was processed with these loaders:
* ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|
|
> .day-disabled {
|
| @apply text-gray-400;
Is there anyway to use @apply
directive in VueJS component using Laravel Mix. This is my webpack.mix.js
const mix = require('laravel-mix');
mix.options({ extractVueStyles: true})
.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
require('postcss-import'),
require('tailwindcss'),
require('postcss-nested'),
require('postcss-custom-properties'),
require('autoprefixer')
]);
Is there anyway to resolve this issue.
It seems this may be a bug in Laravel Mix, see this issue.
Try adding the following to your Mix config (source):
.webpackConfig({
module: {
rules: [
{
test: /\.(postcss)$/,
use: [
'vue-style-loader',
{ loader: 'css-loader', options: { importLoaders: 1 } },
'postcss-loader'
]
}
],
},
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With