mirror of
https://gitee.com/WeBank/fes.js.git
synced 2024-11-29 18:28:09 +08:00
Merge branch 'master' of https://github.com/WeBankFinTech/fes.js
This commit is contained in:
commit
a9813c8c91
@ -45,7 +45,7 @@ export default {
|
||||
};
|
||||
```
|
||||
```js
|
||||
// src/locales/zh-CN.js
|
||||
// src/locales/en-US.js
|
||||
export default {
|
||||
menu: {
|
||||
interface: 'interface'
|
||||
@ -199,4 +199,4 @@ export default {
|
||||
</script>
|
||||
```
|
||||
|
||||
`useI18n()`返回结果是 [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer),提供类似 `t`、`n`、`d` 等转换函数,在模板中使用。
|
||||
`useI18n()`返回结果是 [Composer](https://vue-i18n.intlify.dev/api/composition.html#composer),提供类似 `t`、`n`、`d` 等转换函数,在模板中使用。
|
||||
|
@ -45,8 +45,10 @@ export default function () {
|
||||
require.resolve('./plugins/features/mock'),
|
||||
require.resolve('./plugins/features/dynamicImport'),
|
||||
require.resolve('./plugins/features/runtimePublicPath'),
|
||||
require.resolve('./plugins/features/exportStatic'),
|
||||
require.resolve('./plugins/features/checkVuePackage'),
|
||||
|
||||
|
||||
// misc
|
||||
require.resolve('./plugins/misc/route'),
|
||||
|
||||
|
@ -73,7 +73,7 @@ export async function getBundleAndConfigs({
|
||||
const bundleConfig = await api.applyPlugins({
|
||||
type: api.ApplyPluginsType.modify,
|
||||
key: 'modifyBundleConfig',
|
||||
initialValue: await getConfig(getConfigOpts),
|
||||
initialValue: await getConfig({ api, ...getConfigOpts }),
|
||||
args: {
|
||||
}
|
||||
});
|
||||
|
@ -6,6 +6,7 @@ import {
|
||||
import resolveDefine from './resolveDefine';
|
||||
|
||||
export default async function createHtmlWebpackConfig({
|
||||
api,
|
||||
cwd,
|
||||
config,
|
||||
webpackConfig,
|
||||
@ -38,13 +39,14 @@ export default async function createHtmlWebpackConfig({
|
||||
const defaultHtmlPath = resolve(__dirname, 'index-default.html');
|
||||
const publicCopyIgnore = [];
|
||||
|
||||
if (!multiPageConfig) {
|
||||
// default, single page setup.
|
||||
htmlOptions.template = existsSync(htmlPath)
|
||||
? htmlPath
|
||||
: defaultHtmlPath;
|
||||
// default, single page setup.
|
||||
htmlOptions.template = existsSync(htmlPath)
|
||||
? htmlPath
|
||||
: defaultHtmlPath;
|
||||
|
||||
publicCopyIgnore.push(winPath(htmlOptions.template));
|
||||
publicCopyIgnore.push(winPath(htmlOptions.template));
|
||||
|
||||
if (!multiPageConfig) {
|
||||
webpackConfig
|
||||
.plugin('html')
|
||||
.use(require.resolve('html-webpack-plugin'), [htmlOptions]);
|
||||
@ -52,6 +54,34 @@ export default async function createHtmlWebpackConfig({
|
||||
// TODO 支持多页
|
||||
}
|
||||
|
||||
// 如果需要导出html,则根据路由生成对应的html文件
|
||||
if (config.exportStatic) {
|
||||
const routes = await api.getRoutes();
|
||||
const addHtml = (_routes) => {
|
||||
if (Array.isArray(_routes)) {
|
||||
_routes.forEach((route) => {
|
||||
const _fileName = `${route.path.slice(1) || 'index'}.html`;
|
||||
if (_fileName !== 'index.html') {
|
||||
const _htmlOptions = {
|
||||
...config.html,
|
||||
title: route?.meta?.title || config.html.title || 'fes.js',
|
||||
filename: _fileName,
|
||||
templateParameters: resolveDefine(config, true),
|
||||
mountElementId: config.mountElementId
|
||||
};
|
||||
webpackConfig
|
||||
.plugin(_fileName)
|
||||
.use(require.resolve('html-webpack-plugin'), [_htmlOptions]);
|
||||
}
|
||||
if (route.children && route.children.length) {
|
||||
addHtml(route.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
addHtml(routes);
|
||||
}
|
||||
|
||||
if (headScripts) {
|
||||
const headScriptsMap = await headScripts();
|
||||
webpackConfig
|
||||
|
@ -59,6 +59,7 @@ function genTranspileDepRegex(exclude) {
|
||||
|
||||
|
||||
export default async function getConfig({
|
||||
api,
|
||||
cwd,
|
||||
config,
|
||||
env,
|
||||
@ -221,6 +222,7 @@ export default async function getConfig({
|
||||
|
||||
// --------------- html -----------
|
||||
const { publicCopyIgnore } = await createHtmlWebpackConfig({
|
||||
api,
|
||||
cwd,
|
||||
config,
|
||||
webpackConfig,
|
||||
|
@ -1,10 +1,12 @@
|
||||
// .fes.js 只负责管理编译时配置,只能使用plain Object
|
||||
|
||||
export default {
|
||||
exportStatic: {},
|
||||
base: "/base/",
|
||||
define: {
|
||||
__DEV__: false,
|
||||
},
|
||||
publicPath: "./",
|
||||
html: {
|
||||
title: "海贼王",
|
||||
},
|
||||
|
8
packages/fes-template/src/pages/a/b.vue
Normal file
8
packages/fes-template/src/pages/a/b.vue
Normal file
@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<div>a/b</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
|
||||
};
|
||||
</script>
|
8
packages/fes-template/src/pages/b/index.vue
Normal file
8
packages/fes-template/src/pages/b/index.vue
Normal file
@ -0,0 +1,8 @@
|
||||
<template>
|
||||
<div>b</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user