Skip to content
New issue

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

建议增加 styleLibraryDirectory 选项 #381

Closed
StephenPCG opened this issue Nov 23, 2019 · 1 comment
Closed

建议增加 styleLibraryDirectory 选项 #381

StephenPCG opened this issue Nov 23, 2019 · 1 comment

Comments

@StephenPCG
Copy link
Contributor

场景描述:

我使用 babel-plugin-import 来导入 element-ui,配置如下:

['import', {
  libraryName: 'element-ui',
  style: (name) => {
    // name => 'element-ui/lib/button'
    // output => 'element-ui/lib/theme-chalk/button.css'
    return name.substring(0, 15) + 'theme-chalk/' + name.substring(15) + '.css'
  },
}, 'element-ui'],

该配置可以正常使用。然而,我希望结合 thread-loader 使用,但是 thread-loader 用 JSON.stringify 将 babel-loader 的 options 序列化然后传递给子进程,见 webpack-contrib/thread-loader#75 ,此处 style 为函数时无法传递,导致无法工作。

我知道该问题如果可以在 thread-loader 中解决是最好的,但是由于其进程模型,可能短时间内难以很好的解决,因此考虑在 babel-plugin-import 中增加一个 styleLibraryDirectory,如果配置中提供了

styleLibraryDirectory: 'theme-chalk',

那么使用该选项来构造 css 文件路径,否则仍然使用 style 选项,与现有行为兼容。

@afc163
Copy link
Contributor

afc163 commented Nov 23, 2019

来个 pr 吧。

StephenPCG added a commit to StephenPCG/babel-plugin-import that referenced this issue Nov 23, 2019
StephenPCG added a commit to StephenPCG/babel-plugin-import that referenced this issue Nov 23, 2019
StephenPCG added a commit to StephenPCG/babel-plugin-import that referenced this issue Nov 25, 2019
zhanguangao pushed a commit to zhanguangao/babel-plugin-module-federation-import that referenced this issue Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants