We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrate from cordiverse/yakumo#19
从你的使用场景来看,或许应该改一下那个后缀名判断的条件,把 js 什么的也加进来。你觉得呢?
挺好的,也许改成可配置更好。
const loaders = config.atsc?.loaders || ['.yaml', '.yml'] const ignore = config.atsc?.ignore || ['.ts', '.mts', '.cts', '.tsx', '.mjs', '.cjs', '.js', '.jsx'] const files = await globby(['**'], { cwd: resolve(cwd, rootDir), onlyFiles: true, }) await Promise.all(files.map(async (file) => { const ext = extname(file) if (ignore.includes(ext)) return const src = resolve(cwd, rootDir, file) const dest = resolve(cwd, outDir, file) await fs.mkdir(dirname(dest), { recursive: true }) if (!loaders.includes(ext)) { await fs.copyFile(src, dest) } else if (['.yaml', '.yml'].includes(ext)) { const data = yaml.load(await fs.readFile(src, 'utf8')) await fs.writeFile(dest.slice(0, -ext.length) + '.json', JSON.stringify(data) || '') } }))
另外我不是很明白这里 loaders 的意思,
atsc 在这里只对.yaml,.yml做了处理,即使在 loaders 中配置了其他项,其结果也是 ignore。
.yaml
.yml
如果 loader 指:需要额外加载的文件后缀。也许由用户明确指出需要加载的项会更好,你怎么看?
if(loaders.includes(ext) && ['.yaml', '.yml'].includes(ext)) { const data = yaml.load(await fs.readFile(src, 'utf8')) await fs.writeFile(dest.slice(0, -ext.length) + '.json', JSON.stringify(data) || '') }else if(loaders.includes(ext)) { await fs.copyFile(src, dest) }
但是这样的代码又会引入新的问题,所有的 .yaml 和 .yml 都将被处理为 json。
因此可以移除 loader(用 ingore 替代)。引入配置项,converters: ['.yaml', '.yml'],指示需要转换的项 yaml,yml。
converters: ['.yaml', '.yml']
yaml,yml
const converters = config.atsc?.converters || ['.yaml', '.yml'] const ignore = config.atsc?.ignore || ['.ts', '.mts', '.cts', '.tsx', '.mjs', '.cjs', '.js', '.jsx'] const files = await globby(['**'], { cwd: resolve(cwd, rootDir), onlyFiles: true, }) await Promise.all(files.map(async (file) => { const ext = extname(file) if (ignore.includes(ext)) return const src = resolve(cwd, rootDir, file) const dest = resolve(cwd, outDir, file) await fs.mkdir(dirname(dest), { recursive: true }) if(converters.includes(ext) && ['.yml', '.yaml'].includes()) { const data = yaml.load(await fs.readFile(src, 'utf8')) await fs.writeFile(dest.slice(0, -ext.length) + '.json', JSON.stringify(data) || '') }else { await fs.copyFile(src, dest) } }))
你觉得呢?
既然话题转移到 atsc 上,那我就关闭 issue 和 pr,在 atsc 仓库新开好了。
The text was updated successfully, but these errors were encountered:
allowJS
Successfully merging a pull request may close this issue.
migrate from cordiverse/yakumo#19
挺好的,也许改成可配置更好。
另外我不是很明白这里 loaders 的意思,
atsc 在这里只对
.yaml
,.yml
做了处理,即使在 loaders 中配置了其他项,其结果也是 ignore。如果 loader 指:需要额外加载的文件后缀。也许由用户明确指出需要加载的项会更好,你怎么看?
但是这样的代码又会引入新的问题,所有的
.yaml
和.yml
都将被处理为 json。因此可以移除 loader(用 ingore 替代)。引入配置项,
converters: ['.yaml', '.yml']
,指示需要转换的项yaml,yml
。你觉得呢?
既然话题转移到 atsc 上,那我就关闭 issue 和 pr,在 atsc 仓库新开好了。
The text was updated successfully, but these errors were encountered: