From 4872836b96da7cb3ad61eaf62c56fb4f4a8f3f21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Pereira?= Date: Fri, 15 Jul 2022 18:27:55 -0300 Subject: [PATCH] Update configuration. Add project name var to index title --- index.html | 2 +- src/components/Autocomplete/Autocomplete.vue | 2 +- src/plugins/htmlPlugin.js | 11 +++++++++++ vite.config.js | 16 ++++++++-------- 4 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 src/plugins/htmlPlugin.js diff --git a/index.html b/index.html index 0001989..421959b 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - TaxonWorks public page. (Vite prototype) + <%- project_name %>
diff --git a/src/components/Autocomplete/Autocomplete.vue b/src/components/Autocomplete/Autocomplete.vue index af68387..2ddb645 100644 --- a/src/components/Autocomplete/Autocomplete.vue +++ b/src/components/Autocomplete/Autocomplete.vue @@ -41,7 +41,7 @@ dark:text-white dark:border-slate-700 border-gray-300 - dark:placeholder:text-white + dark:placeholder:text-slate-400 focus:ring-primary-500 focus:border-primary-500" :placeholder="placeholder" diff --git a/src/plugins/htmlPlugin.js b/src/plugins/htmlPlugin.js new file mode 100644 index 0000000..284b1d2 --- /dev/null +++ b/src/plugins/htmlPlugin.js @@ -0,0 +1,11 @@ +export default (data) => ({ + name: 'html-transform', + transformIndexHtml: { + enforce: 'pre', + transform: (html) => { + return html.replace(/<%-(.*?)%>/g, (_, p1) => + data[p1.trim()] || '' + ) + } + } +}) diff --git a/vite.config.js b/vite.config.js index 710bc7c..0217acd 100644 --- a/vite.config.js +++ b/vite.config.js @@ -1,18 +1,18 @@ import { defineConfig, loadEnv } from 'vite' import { loadConfiguration } from './src/utils/loadConfiguration.js' +import path from 'path' +import htmlPlugin from './src/plugins/htmlPlugin.js' import Vue from '@vitejs/plugin-vue' import Markdown from 'vite-plugin-md' -import path from 'path' import Pages from 'vite-plugin-pages' -import Content from '@originjs/vite-plugin-content' -export default ({ mode }) => { - const { VITE_BASE_URL } = loadEnv(mode, process.cwd()) +export default () => { + const configuration = loadConfiguration(__dirname) return defineConfig({ - base: VITE_BASE_URL, + base: configuration.base_url, define: { - __APP_ENV__: loadConfiguration(__dirname), + __APP_ENV__: configuration, __APP_PATH__: () => __dirname }, resolve: { @@ -24,7 +24,6 @@ export default ({ mode }) => { Vue({ include: [/\.vue$/, /\.md$/] }), - Content(), Markdown(), Pages({ dirs: 'pages', @@ -37,7 +36,8 @@ export default ({ mode }) => { return route } } - }) + }), + htmlPlugin(configuration) ], }) }