提交 542c81cd 编写于 作者: D DCloud_LXH

feat: 编译资源放在特定时间的目录下

上级 74ae7838
......@@ -4,9 +4,15 @@ const highlight = require('@vuepress/markdown/lib/highlight')
const translatePlugin = require('./markdown/translate')
const headerPlugin = require('./markdown/header')
const createSidebar = require('./markdown/createSidebar')
const { simplifySlugText, tabs } = require('./utils')
const { simplifySlugText, tabs, getFormattedDate } = require('./utils')
const copyOptions = require('./config/copy');
const nowString = getFormattedDate();
const changeLoaderOptions = (options, key = 'name') => {
if (options && options[key]) options[key] = `${nowString}/${options[key]}`;
return options;
};
const config = {
theme: 'vuepress-theme-uni-app-test',
title: 'uni-app-x',
......@@ -115,6 +121,23 @@ const config = {
'@theme-config',
path.resolve(process.cwd(), 'docs/.vuepress/config')
)
if (!isServer) {
config.output.filename(`${nowString}/${config.output.get('filename')}`); //输出文件名
config.module.rule('images').use('url-loader').tap(changeLoaderOptions);
config.module.rule('fonts').use('url-loader').tap(changeLoaderOptions);
config.module.rule('media').use('url-loader').tap(changeLoaderOptions);
config.module.rule('svg').use('file-loader').tap(changeLoaderOptions);
const extract_css_plugin = config.plugin('extract-css');
const extract_css_plugin_args = extract_css_plugin.get('args');
if (extract_css_plugin_args) {
extract_css_plugin.set(
'args',
extract_css_plugin_args.map(item =>
changeLoaderOptions(item, 'filename')
)
);
}
}
},
patterns: ['**/!(_sidebar).md', '**/*.vue'],
plugins: [
......
......@@ -14,6 +14,21 @@ function simplifySlugText(text) {
return text;
}
function getFormattedDate() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
const formattedDate = `${year}-${month}-${day}_${hours}-${minutes}-${seconds}`;
return formattedDate;
}
// 顺序有要求,会影响 for 循环匹配侧边栏
const tabs = [
'/compiler/', '/dom/', '/uts/', '/collocation/', '/plugin/', '/worktile/', '/component/', '/api/', '/css/', '/'
......@@ -22,5 +37,6 @@ const tabs = [
module.exports = {
isExternal,
simplifySlugText,
getFormattedDate,
tabs: process.env.DOCS_LITE ? [] : tabs
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册