From af561635eae741c9946cc3aa73d9a10361a1068a Mon Sep 17 00:00:00 2001 From: quaqng Date: Tue, 6 Dec 2022 23:33:16 +0700 Subject: [PATCH] support vitejs --- index.html | 44 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 9 +++++++-- vite.config.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 2 deletions(-) create mode 100644 index.html create mode 100644 vite.config.js diff --git a/index.html b/index.html new file mode 100644 index 00000000..8650f468 --- /dev/null +++ b/index.html @@ -0,0 +1,44 @@ + + + + + + + + + + CoreUI Vue.js Admin Template + + + + + + + + + + + + + + + + + + + + + + +
+ + + diff --git a/package.json b/package.json index 2251e0b0..c3c06f5c 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,10 @@ "lint": "vue-cli-service lint", "serve": "vue-cli-service serve", "test:e2e": "vue-cli-service test:e2e", - "test:unit": "vue-cli-service test:unit" + "test:unit": "vue-cli-service test:unit", + "vite-dev": "vite", + "vite-build": "vite build", + "vite-preview": "vite preview" }, "dependencies": { "@coreui/chartjs": "^3.0.0", @@ -34,6 +37,7 @@ "devDependencies": { "@babel/core": "^7.20.2", "@babel/eslint-parser": "^7.19.1", + "@vitejs/plugin-vue": "^3.2.0", "@vue/cli-plugin-babel": "~5.0.8", "@vue/cli-plugin-e2e-cypress": "~5.0.8", "@vue/cli-plugin-eslint": "~5.0.8", @@ -52,6 +56,7 @@ "jest": "^27.5.1", "prettier": "^2.8.0", "sass": "^1.56.1", - "sass-loader": "^12.0.0" + "sass-loader": "^12.0.0", + "vite": "^3.2.5" } } diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 00000000..43939061 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,45 @@ +/** @type {import('vite').UserConfig} */ +import { defineConfig, loadEnv } from 'vite' +import vue from '@vitejs/plugin-vue' +import path from "path"; + +// https://vitejs.dev/config/ +export default defineConfig(({ command, mode }) => { + const path = require('path') + + // Load .env + const env = loadEnv(mode, process.cwd(), '') + process.env = {...process.env, ...env}; + return { + plugins: [vue()], + // base: '/app/', + server: { + port: 3000, + proxy: { + // https://vitejs.dev/config/server-options.html + }, + }, + resolve: { + extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue', 'scss'], + alias: [ + // webpack path resolve to vitejs + { + find: /^~(.*)$/, + replacement: '$1', + }, + { + find: '@/', + replacement: `${path.resolve(__dirname, 'src')}/`, + }, + { + find: '@', + replacement: path.resolve(__dirname, '/src'), + }, + ], + }, + define: { + // vitejs does not support process.env so we have to redefine it + 'process.env': process.env, + }, + } +})