Skip to content

Commit

Permalink
docs: update vite documentation for migrating the custom webpack config
Browse files Browse the repository at this point in the history
  • Loading branch information
jleifeld committed Jan 24, 2025
1 parent caf394c commit 71c3c9c
Showing 1 changed file with 39 additions and 0 deletions.
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 @@ The Vue.js ecosystem has built its own bundler: Vite. Vite is fast, easier to co

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',
}
}
};
};
```

```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

0 comments on commit 71c3c9c

Please sign in to comment.