fix: 修复 vite html 配置问题 (#200)

* fix: 修复 vite html 配置问题

* chore: lock @babel/preset-env
This commit is contained in:
qlin 2023-06-16 11:11:11 +08:00 committed by GitHub
parent 55bbf2fcbf
commit 2f11e29cfc
5 changed files with 24 additions and 15 deletions

View File

@ -36,19 +36,24 @@ export function getInnerCommonConfig(api) {
vue(api.config.viteVuePlugin || {}), vue(api.config.viteVuePlugin || {}),
SFCConfigBlockPlugin, SFCConfigBlockPlugin,
vueJsx(api.config.viteVueJsx || {}), vueJsx(api.config.viteVueJsx || {}),
createHtmlPlugin({ createHtmlPlugin(
minify: true, deepmerge(
// 使用绝对地址在win下会提示没有权限 {
entry: `/src/${api.paths.tmpDir}/fes.js`, minify: true,
template: 'index.html', // 使用绝对地址在win下会提示没有权限
inject: { entry: `/src/${api.paths.tmpDir}/fes.js`,
data: { template: 'index.html',
...resolveRuntimeEnv(publicPath), inject: {
title: api.config.title || 'Fes.js', data: {
mountElementId: api.config.mountElementId, ...resolveRuntimeEnv(publicPath),
title: api.config.title || 'Fes.js',
mountElementId: api.config.mountElementId,
},
},
}, },
}, api.config.viteHtml,
}), ),
),
], ],
resolve: { resolve: {
alias: { alias: {

View File

@ -6,6 +6,7 @@ export default function () {
require.resolve('./registerType'), require.resolve('./registerType'),
// bundle configs // bundle configs
require.resolve('./features/viteHtml'),
require.resolve('./features/viteOption'), require.resolve('./features/viteOption'),
require.resolve('./features/viteVueJsx'), require.resolve('./features/viteVueJsx'),
require.resolve('./features/viteVuePlugin'), require.resolve('./features/viteVuePlugin'),

View File

@ -32,7 +32,7 @@
"@babel/plugin-proposal-function-bind": "^7.18.9", "@babel/plugin-proposal-function-bind": "^7.18.9",
"@babel/plugin-proposal-pipeline-operator": "^7.18.9", "@babel/plugin-proposal-pipeline-operator": "^7.18.9",
"@babel/plugin-transform-runtime": "^7.21.0", "@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", "@babel/preset-typescript": "^7.21.0",
"@fesjs/utils": "^3.0.0", "@fesjs/utils": "^3.0.0",
"@vue/babel-plugin-jsx": "^1.1.1", "@vue/babel-plugin-jsx": "^1.1.1",

View File

@ -1,7 +1,7 @@
import { defineBuildConfig } from '@fesjs/fes'; import { defineBuildConfig } from '@fesjs/fes';
export default defineBuildConfig({ export default defineBuildConfig({
builder: 'webpack', builder: 'vite',
define: { define: {
__DEV__: false, __DEV__: false,
}, },
@ -71,6 +71,9 @@ export default defineBuildConfig({
['1', '有效的'], ['1', '有效的'],
], ],
}, },
viteHtml: {
template: 'hello.html',
},
dynamicImport: true, dynamicImport: true,
monacoEditor: { monacoEditor: {
languages: ['javascript', 'typescript', 'html', 'json'], languages: ['javascript', 'typescript', 'html', 'json'],

2
pnpm-lock.yaml generated
View File

@ -193,7 +193,7 @@ importers:
specifier: ^7.21.0 specifier: ^7.21.0
version: 7.21.0(@babel/core@7.21.3) version: 7.21.0(@babel/core@7.21.3)
'@babel/preset-env': '@babel/preset-env':
specifier: ^7.20.2 specifier: 7.20.2
version: 7.20.2(@babel/core@7.21.3) version: 7.20.2(@babel/core@7.21.3)
'@babel/preset-typescript': '@babel/preset-typescript':
specifier: ^7.21.0 specifier: ^7.21.0