Skip to content

Commit

Permalink
fix(examples): configuration of vite (#1449)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkucmus authored Nov 13, 2024
1 parent d4482d5 commit 8ba9702
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-snakes-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@shopware-pwa/composables-next": patch
---

Add configuration step to README.md
3 changes: 3 additions & 0 deletions examples/b2b-quote-management/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import UnoCSS from "unocss/vite";

export default defineConfig({
plugins: [vue(), UnoCSS()],
optimizeDeps: {
exclude: ["@shopware-pwa/composables-next"],
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
Expand Down
3 changes: 3 additions & 0 deletions examples/blank-playground/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
optimizeDeps: {
exclude: ["@shopware-pwa/composables-next"],
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
Expand Down
3 changes: 3 additions & 0 deletions examples/commercial-quick-order/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
optimizeDeps: {
exclude: ["@shopware-pwa/composables-next"],
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
Expand Down
3 changes: 3 additions & 0 deletions examples/express-checkout/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
optimizeDeps: {
exclude: ["@shopware-pwa/composables-next"],
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
Expand Down
3 changes: 3 additions & 0 deletions examples/login-form/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
optimizeDeps: {
exclude: ["@shopware-pwa/composables-next"],
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
Expand Down
3 changes: 3 additions & 0 deletions examples/responsive-images/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import vue from "@vitejs/plugin-vue";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
optimizeDeps: {
exclude: ["@shopware-pwa/composables-next"],
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
Expand Down
16 changes: 15 additions & 1 deletion packages/composables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,29 @@ app.provide("apiClient", apiClient);
Now, we can create a Vue 3 plugin to install a Shopware context in an app:

```js
// app variable in type of App
import { createShopwareContext } from "@shopware-pwa/composables-next";

// app variable in type of App
const shopwareContext = createShopwareContext(app, {
devStorefrontUrl: "https://your-sales-channel-configured-domain.com",
});
// register a plugin in a Vue instance
app.use(shopwareContext);
```

Exclude `@shopware-pwa/composables-next` package from [pre-building](https://vite.dev/guide/dep-pre-bundling.html#customizing-the-behavior) process:

```ts
// vite.config.js or .ts
...
optimizeDeps: {
exclude: ["@shopware-pwa/composables-next"],
},
...
```

---

> The example does not provide the session handling and that means you need to do few additional steps if you need to keep your session after the page reload (see the chapter below with 🍪)
## Basic usage
Expand Down
4 changes: 3 additions & 1 deletion packages/composables/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { resolve } from "pathe";
export default defineBuildConfig({
entries: ["src/index"],
declaration: true,
rollup: {
inlineDependencies: true,
},
externals: [
"axios",
"vue",
Expand All @@ -16,5 +19,4 @@ export default defineBuildConfig({
"#imports": resolve("./src/index.ts"),
"#shopware": resolve("./types/api-types.ts"),
},
failOnWarn: false,
});

0 comments on commit 8ba9702

Please sign in to comment.