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

docs: update vite documentation for migrating the custom webpack config #1674

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
39 changes: 39 additions & 0 deletions guides/plugins/plugins/administration/system-updates/vite.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,45 @@

For apps there are no consequences as your build process is already decoupled from Shopware. For plugins you only need to get active if you currently extend the webpack config by providing your own `webpack.config.js` file.

### Migrate the custom webpack config to Vite

If you have a custom webpack config, you need to migrate it to Vite. You need to do the following steps:

1. Create a new config file `vite.config.mts` to your plugin in the `YourApp/src/Resources/app/administration/src` directory. Previously you had a `webpack.config.js` one folder above.
2. Remove the old `webpack.config.js` file
3. Make sure to remove all webpack related dependencies from your `package.json` file
4. Make sure to add the Vite dependencies to your `package.json` file

A basic config migration could look like this:

```javascript
// Old Webpack config
module.exports = () => {

Check warning on line 38 in guides/plugins/plugins/administration/system-updates/vite.md

View workflow job for this annotation

GitHub Actions / LanguageTool

[LanguageTool] guides/plugins/plugins/administration/system-updates/vite.md#L38

If a new sentence starts here, add a space and start with an uppercase letter. (LC_AFTER_PERIOD[1]) Suggestions: ` Exports`, ` exports` Rule: https://community.languagetool.org/rule/show/LC_AFTER_PERIOD?lang=en-US&subId=1 Category: CASING
Raw output
guides/plugins/plugins/administration/system-updates/vite.md:38:7: If a new sentence starts here, add a space and start with an uppercase letter. (LC_AFTER_PERIOD[1])
 Suggestions: ` Exports`, ` exports`
 Rule: https://community.languagetool.org/rule/show/LC_AFTER_PERIOD?lang=en-US&subId=1
 Category: CASING
return {
resolve: {
alias: {
@example: 'src/example',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@example: 'src/example',
`@example`: 'src/example',

}
}
};
};
```

```typescript
// New Vite config
import { defineConfig } from 'vite';

export default defineConfig({
resolve: {
alias: {
'@example': 'src/example',
},
},
});
```

Of course, this is a very basic example. The Vite config can be much more complex and powerful. You can find more information about the Vite config in the [Vite documentation](https://vitejs.dev/config/). Depending on your webpack config, the migration can be very individual.

## Implementation details

In this section we'll document the implementation details of the new Vite setup.
Expand Down
Loading