这些设置适用于我在 Laravel 8、Mix 6 和 Tailwind v2 的新项目中:
tailwind.config.js
除了添加的清除设置外,此文件未修改:
module.exports = {
purge: [
'resources/views/**/*.blade.php',
'resources/js/**/*.js',
'./resources/**/*.vue',
],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
webpack.mix.js
除了顺风的导入和附加的顺风设置外,此文件未修改。{}
注意那里的第二个参数中的额外内容。
const mix = require('laravel-mix');
const tailwindcss = require('tailwindcss');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/js/app.js', 'public/js')
.vue()
.sass('resources/sass/app.scss', 'public/css', {}, [
tailwindcss('tailwind.config.js'),
])
.options({
processCssUrls: false,
});
应用程序.scss
我现在刚刚添加了所有三个顺风指令。输出非常大,因此可能建议进行一些编辑。
@tailwind base;
@tailwind components;
@tailwind utilities;
另一个答案中的 URL 对于使其正常工作至关重要。这个在这里:https ://laracasts.com/discuss/channels/elixir/multiple-tailwind-configs-for-theming