diff --git a/README.md b/README.md index f1b71d4..7712c13 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,26 @@ -# hello-world +# Vue CLI Multisite Base Example + +Just some stuff I hacked together to get a vue-cli created app to support +multiple sites. Key things to look at compared to a base `vue create ` +site: + +* package.json: + * Customizes the `npm run build` commands to support multiple sites, an "admin" + and a "main" site. Each one has a custom dist/ output folder (--dest option) + and a custom entry point (e.g. "./src/admin/index.js" instead of default + "./src/main.js") +* vue.config.js: + * This file needs to be **added** to a Vue project, as it's not there by default. + It configures the html-webpack-plugin to change the name of the "public" folder + that gets put into the dist/ folder; so each site can have its own public + folder. + * Uses environment variable SITE_NAME to choose the public folder to use. + * custom-public/ is for the admin site and added a "hello.txt" to verify + correct functionality. The main site uses the public/ folder like normal. + +So when you run `npm run build-admin` it creates `dist-admin/` taking the +custom-public folder and the admin entrypoint. `npm run build-main` creates the +`dist/` folder and the normal public folder. ## Project setup ``` diff --git a/custom-public/favicon.ico b/custom-public/favicon.ico new file mode 100644 index 0000000..df36fcf Binary files /dev/null and b/custom-public/favicon.ico differ diff --git a/custom-public/hello-world.txt b/custom-public/hello-world.txt new file mode 100644 index 0000000..e69de29 diff --git a/custom-public/index.html b/custom-public/index.html new file mode 100644 index 0000000..519579e --- /dev/null +++ b/custom-public/index.html @@ -0,0 +1,17 @@ + + + + + + + + hello-world + + + +
+ + + diff --git a/package.json b/package.json index dc9e8ca..db8ee76 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "private": true, "scripts": { "serve": "vue-cli-service serve", - "build": "vue-cli-service build", + "build-admin": "SITE_NAME=admin vue-cli-service build --dest admin-dist ./src/admin/index.js", + "build": "SITE_NAME=main vue-cli-service build --dest dist ./src/main/index.js", "lint": "vue-cli-service lint" }, "dependencies": { diff --git a/public/index.html b/public/index.html index 519579e..f9ffa2d 100644 --- a/public/index.html +++ b/public/index.html @@ -1,3 +1,4 @@ + @@ -5,7 +6,7 @@ - hello-world + CUSTOM hello-world