fix: 修复 vite html 配置问题

This commit is contained in:
winixt 2023-06-16 11:02:53 +08:00
parent 6b6e703c54
commit 8df71ca738
3 changed files with 22 additions and 13 deletions

View File

@ -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: {

View File

@ -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'),

View File

@ -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'],