Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: compile error following upgrade.md's vite to mix guide #231

Merged
merged 5 commits into from
Jul 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 59 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ Then you will need to specify the base URL for assets in your application's entr

### Optional: Configure Tailwind

If you are using Tailwind, perhaps with one of Laravel's starter kits, you will need migrate your `tailwind.config.js` to use [Vite compatible imports](#vite-compatible-imports) and exports.
If you are using Tailwind, perhaps with one of Laravel's starter kits, you will need to migrate your `tailwind.config.js` configuration file to use [Vite compatible imports](#vite-compatible-imports) and exports:

```diff
- const defaultTheme = require('tailwindcss/defaultTheme');
Expand Down Expand Up @@ -459,6 +459,12 @@ Update your NPM scripts in `package.json`:
}
```

You should also remove the `type` key by running the following command:

```shell
npm pkg delete type
```

#### Inertia

Vite requires a helper function to import page components which is not required with Laravel Mix. You can remove this as follows:
Expand Down Expand Up @@ -538,3 +544,55 @@ You may also wish to remove any `.gitignore` paths you are no longer using:
- /bootstrap/ssr
- /public/build
```

### Optional: Configure Tailwind

If you are using Tailwind, perhaps with one of Laravel's starter kits, you will need to update your `tailwind.config.js` configuration file to use CommonJS imports and exports:

```diff
- import defaultTheme from 'tailwindcss/defaultTheme';
- import forms from '@tailwindcss/forms';
+ const defaultTheme = require('tailwindcss/defaultTheme');

- export default {
+ module.exports = {
content: [
'./vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php',
'./storage/framework/views/*.php',
'./resources/views/**/*.blade.php',
'./resources/js/**/*.vue',
],

theme: {
extend: {
fontFamily: {
sans: ['Figtree', ...defaultTheme.fontFamily.sans],
},
},
},

- plugins: [forms],
+ plugins: [require('@tailwindcss/forms')],
};
```

You may also migrate any PostCSS plugins from your `postcss.config.js` file to your `webpack.mix.js` file:

```diff
mix.js('resources/js/app.js', 'public/js')
.postCss('resources/css/app.css', 'public/css', [
- //
+ require("tailwindcss"),
]);
```

> **Note**
> You do not need to include the `autoprefixer` plugin as Laravel Mix includes this by default.

If you are using other PostCSS plugins, such as `postcss-import`, you will need to include them in your configuration. See the [Laravel Mix PostCSS documentation](https://laravel-mix.com/docs/6.0/postcss) for more information.

Finally, you may also remove your PostCSS config file:

```shell
rm postcss.config.js
```