Home > OS >  Compil sass in laravel 8
Compil sass in laravel 8

Time:12-06

I want compile sass in laravel, and i have this error :

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
ValidationError: Invalid options object. Sass Loader has been initialized using an options object that does not match the API schema.
 - options has an unknown property '0'. These properties are valid:
   object { implementation?, sassOptions?, additionalData?, sourceMap?, webpackImporter?, warnRuleAsWarning? }
    at validate (/home/swan/skip/node_modules/webpack/node_modules/schema-utils/dist/validate.js:105:11)
    at Object.getOptions (/home/swan/skip/node_modules/webpack/lib/NormalModule.js:578:19)
    at Object.loader (/home/swan/skip/node_modules/sass-loader/dist/index.js:25:24)
    at processResult (/home/swan/skip/node_modules/webpack/lib/NormalModule.js:751:19)
    at /home/swan/skip/node_modules/webpack/lib/NormalModule.js:853:5
    at /home/swan/skip/node_modules/loader-runner/lib/LoaderRunner.js:399:11
    at /home/swan/skip/node_modules/loader-runner/lib/LoaderRunner.js:251:18

1 ERROR in child compilations (Use 'stats.children: true' resp. '--stats-children' for more details)
webpack compiled with 2 errors

This my code in webpack.mix.js

mix.js('resources/js/app.js', 'public/js')
    .sass('resources/scss/app.scss', 'public/css', [
        require('tailwindcss'),
    ]);

CodePudding user response:

The definition for the sass method is:

sass(src, output, pluginOptions = {}, postCssPlugins = [])

So, it's the 4th argument that's for the postcss plugins. Just pass an empty object as the 3rd argument:

.sass('resources/scss/app.scss', 'public/css', {}, [
    require('tailwindcss'),
]);
  • Related