Skip to content

Commit

Permalink
chore: enhance workspace management
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jul 31, 2022
1 parent f8680d9 commit a0d32ee
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 362 deletions.
167 changes: 0 additions & 167 deletions build/compile.ts

This file was deleted.

101 changes: 0 additions & 101 deletions build/publish.ts

This file was deleted.

47 changes: 0 additions & 47 deletions build/release.ts

This file was deleted.

2 changes: 1 addition & 1 deletion build/template/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@koishijs/test",
"name": "test",
"version": "1.0.0",
"private": true,
"scripts": {
Expand Down
28 changes: 28 additions & 0 deletions build/yaml.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { addHook } from 'yakumo'
import { Plugin } from 'esbuild'
import {} from 'yakumo-esbuild'
import yaml from 'js-yaml'
import { resolve } from 'path'
import { promises as fsp } from 'fs'

const yamlPlugin = (options: yaml.LoadOptions = {}): Plugin => ({
name: 'i18n',
setup(build) {
build.onResolve({ filter: /\/locales\/[\w-]+$/ }, ({ path, resolveDir }) => ({
path: resolve(resolveDir, path) + '.yml',
namespace: 'yaml',
}))

build.onLoad({ namespace: 'yaml', filter: /.*/ }, async ({ path }) => {
const source = await fsp.readFile(path, 'utf8')
return {
loader: 'json',
contents: JSON.stringify(yaml.load(source, options)),
}
})
},
})

addHook('esbuild.before', (options) => {
options.plugins.push(yamlPlugin())
})
Loading

0 comments on commit a0d32ee

Please sign in to comment.