@adamdickinson/react-cosmos-esbuild 中文文档教程
React Cosmos ESbuild
兼容 ESbuild 的 React Cosmos。
Installation
npm install @adamdickinson/react-cosmos-esbuild
或者
yarn add @adamdickinson/react-cosmos-esbuild
Usage
如果它是一个足够简单的构建过程,你可以完全摆脱运行:
yarn cosmos-esbuild
这样做运行 cosmos,以及带有默认的 cosmos 兼容的 esbuild 配置。
然而,很多 esbuild 驱动的项目有一些相当复杂的 要求,所以这个包也适应了。 通过指定一个 esbuildConfigPath
在你的 cosmos 配置中,你可以注入你自己的 esbuild 配置以调整此包使用的 esbuild 配置。
示例 cosmos.config.json:
{
"esbuildConfigPath": "./scripts/config.js"
}
示例 config.js:
module.exports = {
define: {
'process.env.RUNNING_COSMOS', 'true'
}
}
然后,此配置将用作 esbuild runner 的基线配置 用于为 cosmos 提供动力的方法如下:
{
...config,
bundle: true,
entryPoints: [MAIN_TS_PATH],
outfile: MAIN_JS_PATH,
outdir: undefined
}
换句话说,bundle
、entryPoints
、outfile
的任何自定义配置值 和 outdir
将被覆盖,以便包与 cosmos 一起工作。
Got some things you'd like to see?
启动 PR! 标准很高,但反馈是任何标准的基石 好的 pull request 所以期待对任何贡献的热爱。
React Cosmos ESbuild
ESbuild-compatible React Cosmos.
Installation
npm install @adamdickinson/react-cosmos-esbuild
or
yarn add @adamdickinson/react-cosmos-esbuild
Usage
If it's a simple enough build process, you can totally get away with just running:
yarn cosmos-esbuild
Doing so runs cosmos, as well as esbuild with a default, cosmos-compatible config.
However, a lot of esbuild-driven projects have some rather complex requirements, so this package accommodates that too. By specifying a esbuildConfigPath
in your cosmos config, you can inject your own esbuild config in to adjust the esbuild config this package uses.
Sample cosmos.config.json:
{
"esbuildConfigPath": "./scripts/config.js"
}
Sample config.js:
module.exports = {
define: {
'process.env.RUNNING_COSMOS', 'true'
}
}
This config will then be used as the baseline config for the esbuild runner that is used to power cosmos as follows:
{
...config,
bundle: true,
entryPoints: [MAIN_TS_PATH],
outfile: MAIN_JS_PATH,
outdir: undefined
}
In other words, any custom config values for bundle
, entryPoints
, outfile
and outdir
will be overridden in order for the package to work with cosmos.
Got some things you'd like to see?
Spin up a PR! Standards are pretty high, but feedback is a cornerstone of any good pull request so expect much love for any contributions.