Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I've just started a project and I need to use laravel-mix in laravel 8 version and When I want to run npm run dev it gives me the error below, please check it out

[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: '=='
}

and these are my codes inside 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');

I really appreciate it if you solved this problem

thanks in advance

question from:https://stackoverflow.com/questions/65935326/assertionerror-err-assertion-mix-postcss-is-missing-required-parameter-1-src

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
456 views
Welcome To Ask or Share your Answers For Others

1 Answer

as laravel 8 come with laravel-mix 6 so you need to change these

Run npm install postcss-custom-properties --save-dev

then change

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...