You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mix provides the `mix.css()` command for basic CSS compilation. Here's an example that imports the Normalize CSS library and adds a single rule.
9
+
10
+
```css
11
+
/* src/app.css */
12
+
13
+
@import'~normalize.css/normalize.css';
14
+
15
+
body {
16
+
color: red;
17
+
}
18
+
```
19
+
20
+
We can now add CSS compilation to our `webpack.mix.js` file, like so:
21
+
22
+
```js
23
+
// webpack.mix.js
24
+
let mix =require('laravel-mix');
25
+
26
+
mix.css('src/app.css', 'dist');
27
+
```
28
+
29
+
Run webpack with `npx mix` and you'll find a `/dist/app.css` file that contains the full Normalize library, as well as your `body` rule.
30
+
31
+
Easy!
32
+
33
+
### Advanced Usage
34
+
35
+
As you'll find in the next section, `mix.css()` is an alias for `mix.postCss()`. This means you have full access to the entire PostCSS plugin ecosystem as part of your compilation.
Copy file name to clipboardExpand all lines: docs/postcss.md
+5-3
Original file line number
Diff line number
Diff line change
@@ -1,12 +1,12 @@
1
-
# PostCss Preprocessing
1
+
# PostCSS Preprocessing
2
2
3
3
-[Basic Usage](#basic-usage)
4
4
-[Autoprefixer](#autoprefixer)
5
5
6
6
### Basic Usage
7
7
8
8
Here's a quick example to get you started. Imagine that you have the following CSS file that needs to be compiled and piped through a series of PostCSS plugins. In the example below,
9
-
we'll need to pull in the `postcss-custom-properties`PostCss plugin.
9
+
we'll need to pull in the `postcss-custom-properties`PostCSS plugin.
10
10
11
11
```css
12
12
:root {
@@ -18,7 +18,7 @@ we'll need to pull in the `postcss-custom-properties` PostCss plugin.
18
18
}
19
19
```
20
20
21
-
No problem. Let's add PostCss compilation to our `webpack.mix.js` file.
21
+
No problem. Let's add PostCSS compilation to our `webpack.mix.js` file.
22
22
23
23
```js
24
24
// webpack.mix.js
@@ -28,6 +28,8 @@ let mix = require('laravel-mix');
> Tip: `mix.postCss()` and `mix.css()` are aliases. Either option works for all examples in this section.
32
+
31
33
Notice how, as the third argument to `mix.postCss()`, we can provide an optional array of PostCSS plugins that should be included as part of the build.
32
34
33
35
Compile this down as usual \(`npx mix`\), and you'll find a `/dist/app.css` file that contains:
0 commit comments