From c2703abc98206a40f39a5f547b30a1fd86b0e000 Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Tue, 13 Apr 2021 15:13:54 +0200 Subject: [PATCH] Add local next.config to Vendure provider, update docs --- framework/commerce/config.js | 2 +- framework/vendure/.env.template | 1 + framework/vendure/README.md | 37 ++++---------------------------- framework/vendure/next.config.js | 8 +++++++ 4 files changed, 14 insertions(+), 34 deletions(-) create mode 100644 framework/vendure/.env.template create mode 100644 framework/vendure/next.config.js diff --git a/framework/commerce/config.js b/framework/commerce/config.js index dc20b518e..dc016d47a 100644 --- a/framework/commerce/config.js +++ b/framework/commerce/config.js @@ -7,7 +7,7 @@ const fs = require('fs') const merge = require('deepmerge') const prettier = require('prettier') -const PROVIDERS = ['bigcommerce', 'shopify', 'swell'] +const PROVIDERS = ['bigcommerce', 'shopify', 'swell', 'vendure'] function getProviderName() { return ( diff --git a/framework/vendure/.env.template b/framework/vendure/.env.template new file mode 100644 index 000000000..d8f7f14b5 --- /dev/null +++ b/framework/vendure/.env.template @@ -0,0 +1 @@ +NEXT_PUBLIC_VENDURE_SHOP_API_URL=http://localhost:3001/shop-api diff --git a/framework/vendure/README.md b/framework/vendure/README.md index a528b50a0..77b61d7eb 100644 --- a/framework/vendure/README.md +++ b/framework/vendure/README.md @@ -4,13 +4,7 @@ UI hooks and data fetching methods built from the ground up for e-commerce appli ## Usage -### 1. Choose a Vendure server - -For the fastest start, you can point to the live Vendure demo server which runs at https://demo.vendure.io. This lets you work with the Vendure data hooks without needing to set up a local server. - -If you want to have more control over the server, then getting up an running with a local server is only slightly more work: - -#### 1a. Running a local Vendure server +#### 1. Running a local Vendure server 1. Install Vendure locally with one command: ```shell @@ -36,35 +30,12 @@ If you want to have more control over the server, then getting up an running wit ### 2. Set up the Commerce storefront 1. Clone this repo and install its dependencies with `yarn install` or `npm install` -2. Change the paths in [tsconfig.json](../../tsconfig.json) to point to the Vendure hooks: - ```diff - - "@framework/*": ["framework/bigcommerce/*"], - - "@framework": ["framework/bigcommerce"] - + "@framework/*": ["framework/vendure/*"], - + "@framework": ["framework/vendure"] +2. Set the Vendure provider and API URL in your `.env.local` file: ``` -3. Set the Vendure Shop API URL in your `.env.local` file: - ```sh + COMMERCE_PROVIDER=vendure NEXT_PUBLIC_VENDURE_SHOP_API_URL=http://localhost:3001/shop-api ``` - or if using the live demo server: - ```sh - NEXT_PUBLIC_VENDURE_SHOP_API_URL=https://demo.vendure.io/shop-api - ``` -4. Add the server domain to the `images` property next.config.js file as per the [image optimization docs](https://nextjs.org/docs/basic-features/image-optimization#domains) - ```js - module.exports = { - // ... - images: { - domains: [ - 'localhost', - // or - 'demo.vendure.io', - ], - }, - } - ``` -5. With the Vendure server running, start this project using `yarn dev` or `npm run dev`. +3. With the Vendure server running, start this project using `yarn dev` or `npm run dev`. ## Known Limitations diff --git a/framework/vendure/next.config.js b/framework/vendure/next.config.js new file mode 100644 index 000000000..ce46b706f --- /dev/null +++ b/framework/vendure/next.config.js @@ -0,0 +1,8 @@ +const commerce = require('./commerce.config.json') + +module.exports = { + commerce, + images: { + domains: ['localhost'], + }, +}