【发布时间】:2020-03-09 21:55:37
【问题描述】:
我在 Laravel 中使用 Tailwind CSS 和这样的 VueJS 组件。
<template>
</template>
<script>
</script>
<style lang="postcss" scoped>
.day-disabled {
@apply text-gray-400;
}
</style>
但是它抱怨
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;
有没有在使用 Laravel Mix 的 VueJS 组件中使用 @apply 指令。这是我的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')
]);
有没有办法解决这个问题。
【问题讨论】:
-
你是否在 Vue 中使用单文件组件,你可能还需要 vue-loader。错误是关于
.day-disabled而不是@apply -
我有。如果我删除 @apply 一切正常。
-
对 postcss 不是很熟悉,但你的混音选项中是否需要
require('postcss-apply')? -
我不确定。但假设我不需要这个,因为它适用于 Vue 组件之外的 CSS。
标签: laravel vue.js webpack laravel-mix tailwind-css