buildPreset功能是否有点鸡肋? #4060
Closed
zhangfisher
started this conversation in
General
Replies: 1 comment
-
目前如果想要在原本 import moduleTools, { defineConfig } from "@modern-js/module-tools";
export default defineConfig({
plugins: [moduleTools()],
buildPreset({ extendPreset }) {
return extendPreset("npm-library-es2018", {
sourceMap: true,
minify: 'esbuild',
});
},
}) 如果你想要针对 import moduleTools, { defineConfig } from "@modern-js/module-tools";
export default defineConfig({
plugins: [moduleTools()],
buildPreset({ preset }) {
const configs = [];
// 遍历 npm-library-es2018 对应的每个构建配置
for (const config of preset["npm-library-es2018"]) {
if (config.format === "esm" || /*其他判断条件*/) {
// 修改配置,并增加到新的构建配置数组中。
configs.push({
...config,
// add new config
});
} else if (...) {
} else {
}
}
return configs;
},
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
最近正式发布VoerkaI18n 2.0,准备尝试使用
@modern-js/module-tools
来构建,发现一个问题使用
buildPreset: "npm-library-es2018"
可以输出esm
和cjs
产物,但是我发现没有sourceMap
和miniify
。好像也没有提供配置方式,这就有点尴尬了,又要动用
buildConfig
?Beta Was this translation helpful? Give feedback.
All reactions