3

My current webpack.mix.js configuration is:

mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
    require('postcss-import'),
    require('tailwindcss'),
]).extract();

If I have another CSS, let's say 'plugin-1.css', how can I merge both so that I get an output of one app.css?

I tried ['resources/css/app.css', 'plugin-1.css'] but that's not an option.

3 Answers 3

6

The solution was to import all the required css into one main css file, then use that inside the mix chain:

app.css:

@import 'resources/css/plugin-1.css';
@import 'resources/css/plugin-2.css';

[the content...]
Sign up to request clarification or add additional context in comments.

Comments

2

I usually use like this

mix.styles([
'resources/css/plugin-1.css',
'resources/css/plugin-2.css'
], 'public/assets/css/app.css');

Comments

1

You chain them

mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
    require('postcss-import'),
    require('tailwindcss'),
]).postCss('resources/css/plugin-1.css', 'public/css', [
    require('postcss-import'),
    require('tailwindcss'),
]).extract();

1 Comment

this will end up with 2 output files: app.css AND plugin-1.css I need them to be merged into one file. I tried to force the output file name to 'public/css/app.css' for both but if I do that, I'll end up with one file BUT only from the plugin-1.css (overwriting will happen, not append)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.