This package adds a cssPartial
option to Laravel Mix, which copies CSS code into a partial file.
First, install the extension.
npm install laravel-mix-css-partial --save-dev
Then, require it within your webpack.mix.js
file:
let mix = require('laravel-mix');
require('laravel-mix-css-partial');
mix.cssPartial('css/gallery.scss', 'partials/gallery-css.php');
Note: If you are using setPublicPath
option in your mix file then declare setPublicPath
option before cssPartial
option.
mix.setPublicPath('dist').cssPartial('css/gallery.scss', 'partials/gallery-css.php');
sass
less
stylus
postCss
For Sass, less, stylus files you may provide plugin options as the third argument and postCssPlugins as the fourth argument.
mix.cssPartial('src', 'partial_path', 'pluginOptions', 'postCssPlugins');
For the .css
files you may provide postCssPlugins as the third argument.
mix.cssPartial('gallery.css', 'partials/gallery-css.php', [
require('tailwindcss'),
]);