From 2f11e29cfc3cd2eca1d0db84a64d5c472fc3bc91 Mon Sep 17 00:00:00 2001 From: qlin Date: Fri, 16 Jun 2023 11:11:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20vite=20html=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=97=AE=E9=A2=98=20(#200)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复 vite html 配置问题 * chore: lock @babel/preset-env --- .../fes-builder-vite/src/common/getConfig.js | 29 +++++++++++-------- packages/fes-builder-vite/src/index.js | 1 + packages/fes-builder-webpack/package.json | 2 +- packages/fes-template-vite/.fes.js | 5 +++- pnpm-lock.yaml | 2 +- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/packages/fes-builder-vite/src/common/getConfig.js b/packages/fes-builder-vite/src/common/getConfig.js index a6c2099a..a434bc86 100644 --- a/packages/fes-builder-vite/src/common/getConfig.js +++ b/packages/fes-builder-vite/src/common/getConfig.js @@ -36,19 +36,24 @@ export function getInnerCommonConfig(api) { vue(api.config.viteVuePlugin || {}), SFCConfigBlockPlugin, vueJsx(api.config.viteVueJsx || {}), - createHtmlPlugin({ - minify: true, - // 使用绝对地址在win下会提示没有权限 - entry: `/src/${api.paths.tmpDir}/fes.js`, - template: 'index.html', - inject: { - data: { - ...resolveRuntimeEnv(publicPath), - title: api.config.title || 'Fes.js', - mountElementId: api.config.mountElementId, + createHtmlPlugin( + deepmerge( + { + minify: true, + // 使用绝对地址在win下会提示没有权限 + entry: `/src/${api.paths.tmpDir}/fes.js`, + template: 'index.html', + inject: { + data: { + ...resolveRuntimeEnv(publicPath), + title: api.config.title || 'Fes.js', + mountElementId: api.config.mountElementId, + }, + }, }, - }, - }), + api.config.viteHtml, + ), + ), ], resolve: { alias: { diff --git a/packages/fes-builder-vite/src/index.js b/packages/fes-builder-vite/src/index.js index ddf09b18..e2bf8559 100644 --- a/packages/fes-builder-vite/src/index.js +++ b/packages/fes-builder-vite/src/index.js @@ -6,6 +6,7 @@ export default function () { require.resolve('./registerType'), // bundle configs + require.resolve('./features/viteHtml'), require.resolve('./features/viteOption'), require.resolve('./features/viteVueJsx'), require.resolve('./features/viteVuePlugin'), diff --git a/packages/fes-builder-webpack/package.json b/packages/fes-builder-webpack/package.json index 7003e4ee..01399089 100644 --- a/packages/fes-builder-webpack/package.json +++ b/packages/fes-builder-webpack/package.json @@ -32,7 +32,7 @@ "@babel/plugin-proposal-function-bind": "^7.18.9", "@babel/plugin-proposal-pipeline-operator": "^7.18.9", "@babel/plugin-transform-runtime": "^7.21.0", - "@babel/preset-env": "^7.20.2", + "@babel/preset-env": "7.20.2", "@babel/preset-typescript": "^7.21.0", "@fesjs/utils": "^3.0.0", "@vue/babel-plugin-jsx": "^1.1.1", diff --git a/packages/fes-template-vite/.fes.js b/packages/fes-template-vite/.fes.js index 546447c1..b54cd286 100644 --- a/packages/fes-template-vite/.fes.js +++ b/packages/fes-template-vite/.fes.js @@ -1,7 +1,7 @@ import { defineBuildConfig } from '@fesjs/fes'; export default defineBuildConfig({ - builder: 'webpack', + builder: 'vite', define: { __DEV__: false, }, @@ -71,6 +71,9 @@ export default defineBuildConfig({ ['1', '有效的'], ], }, + viteHtml: { + template: 'hello.html', + }, dynamicImport: true, monacoEditor: { languages: ['javascript', 'typescript', 'html', 'json'], diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f05a785d..28085302 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -193,7 +193,7 @@ importers: specifier: ^7.21.0 version: 7.21.0(@babel/core@7.21.3) '@babel/preset-env': - specifier: ^7.20.2 + specifier: 7.20.2 version: 7.20.2(@babel/core@7.21.3) '@babel/preset-typescript': specifier: ^7.21.0