From 7b285a1a71770507a83613cdfe02589819f68584 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 13 Mar 2021 11:43:07 +0900 Subject: [PATCH] gulp refactor --- gulpfile.ts | 8 -------- src/client/pages/doc.vue | 2 +- src/server/web/index.ts | 8 ++++++++ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gulpfile.ts b/gulpfile.ts index 0cdd016fd..771a5c0e3 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -77,17 +77,9 @@ gulp.task('cleanall', gulp.parallel('clean', cb => rimraf('./node_modules', cb) )); -gulp.task('copy:docs', () => - gulp.src([ - './src/docs/**/*', - ]) - .pipe(gulp.dest('./built/assets/docs/')) -); - gulp.task('build', gulp.parallel( 'build:ts', 'build:copy', - 'copy:docs', )); gulp.task('default', gulp.task('build')); diff --git a/src/client/pages/doc.vue b/src/client/pages/doc.vue index 3379a5fe6..ed4eae4d0 100644 --- a/src/client/pages/doc.vue +++ b/src/client/pages/doc.vue @@ -60,7 +60,7 @@ export default defineComponent({ methods: { fetchDoc() { - fetch(`${url}/assets/docs/${lang}/${this.doc}.md`).then(res => res.text()).then(md => { + fetch(`${url}/doc-assets/${lang}/${this.doc}.md`).then(res => res.text()).then(md => { this.parse(md); }); }, diff --git a/src/server/web/index.ts b/src/server/web/index.ts index 7b0b82eed..c1f879f91 100644 --- a/src/server/web/index.ts +++ b/src/server/web/index.ts @@ -29,6 +29,7 @@ const markdown = MarkdownIt({ }); const staticAssets = `${__dirname}/../../../assets/`; +const docAssets = `${__dirname}/../../../src/docs/`; const assets = `${__dirname}/../../assets/`; // Init app @@ -65,6 +66,13 @@ router.get('/static-assets/(.*)', async ctx => { }); }); +router.get('/doc-assets/(.*)', async ctx => { + await send(ctx as any, ctx.path.replace('/doc-assets/', ''), { + root: docAssets, + maxage: ms('7 days'), + }); +}); + router.get('/assets/(.*)', async ctx => { await send(ctx as any, ctx.path.replace('/assets/', ''), { root: assets,