Laravel mix.sass "prependData" 没有向 scss 文件提供数据

Laravel mix.sass "prependData" not supplying data to scss files

我有一个混合文件,我正在向它传递这样的数据:

mix.sass('resources/sass/styles.scss', 'public/assets/css')
    .options({
        processCssUrls: false,
        prependData: '$test: testing prepend;',
        postCss: [tailwindcss('./tailwind.config.js')],
    });

我正在这样做:

body {
    content: $test;
}

测试我是否得到 $test 变量。 但是,当我 运行 应用程序时,我得到:

我做错了什么?

P.S: php artisan --version returns: 8.48.1

使用 prependData 不是在 options 内,而是作为 sass 方法的第三个参数,就像它说的 here

Behind the scenes, Laravel Mix of course defers to webpack's sass-loader to load and compile your Sass files. From time to time, you may need to override the default options that we pass to it. Use the third argument to mix.sass() in these scenarios.

mix.sass('src/app.scss', 'dist', {
    sassOptions: {
        outputStyle: 'nested'
    }
});

所以你的情况应该是

mix.sass('resources/sass/styles.scss', 'public/assets/css', {
        additionalData: '$test: testing prepend;',
    })
    .options({
        processCssUrls: false,
        postCss: [tailwindcss('./tailwind.config.js')],
    });