AssertionError ERR_ASSERTION: mix.postCss() 缺少必需的参数 1: src

AssertionError ERR_ASSERTION: mix.postCss() is missing required parameter 1: src

我刚刚开始一个项目,我需要在 laravel 8 版本中使用 laravel-mix,当我想要 运行 npm run dev 时,它给了我以下错误,请检查

[webpack-cli] AssertionError [ERR_ASSERTION]: mix.postCss() is missing required parameter 1: src
    at Function.preprocessor (/home/amir/mine/projects/AmirPay/node_modules/laravel-mix/src/Assert.js:33:9)
    at PostCss.register (/home/amir/mine/projects/AmirPay/node_modules/laravel-mix/src/components/PostCss.js:28:16)
    at Object.components.<computed> [as css] (/home/amir/mine/projects/AmirPay/node_modules/laravel-mix/src/components/ComponentRegistrar.js:133:53)
    at Object.<anonymous> (/home/amir/mine/projects/AmirPay/webpack.mix.js:22:5)
    at Module._compile (/home/amir/mine/projects/AmirPay/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (/home/amir/mine/projects/AmirPay/node_modules/v8-compile-cache/v8-compile-cache.js:159:20) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

这些是我在里面的代码 webpack.mix.js

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel applications. By default, we are compiling the CSS
 | file for the application as well as bundling up all the JS files.
 |
 */

// const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
    .postCss('resources/css/app.css', 'public/css');
// require('resources/css/bootstrap-rtl.min.css'),



mix.css([
    'resources/css/adminlte.css.map',
    'resources/css/adminlte.min.css',
    'resources/css/bootstrap-rtl.min.css',
    'resources/css/custom-style.css',
    'resources/css/persian-datepicker.min.css',
], 'public/dashboard/css/admin.min.css');

mix.scss([
    'resources/scss/*.scss'
], 'public/dashboard/scss/admin.min.scss');


mix.js([
    'resources/js/build/js/.jscsrc'
], 'public/dashboard/js/.jscsrc');

mix.combine([
    'resources/js/build/js/*.js'
], 'public/dashboard/js/admin_build.min.js');

mix.combine([
    'resources/js/dist/js/*.js',
    'resources/js/dist/js/pages/dashboard2.js',
], 'public/dashboard/js/admin_dist.min.js');

如果你解决了这个问题,我真的很感激

提前致谢

因为 laravel 8 带有 laravel-mix 6 所以你需要改变这些

运行 npm install postcss-custom-properties --save-dev

然后改变

mix.js('resources/js/app.js', 'public/js')
    .postCss('resources/css/app.css', 'public/css',[
        require('postcss-custom-properties')
    ]);

ref link https://laravel-mix.com/docs/6.0/postcss