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

webpack版本导致mini-css-extract-plugin出现错误 #12

Closed
LeoEatle opened this issue Dec 5, 2018 · 3 comments
Closed

webpack版本导致mini-css-extract-plugin出现错误 #12

LeoEatle opened this issue Dec 5, 2018 · 3 comments

Comments

@LeoEatle
Copy link
Member

LeoEatle commented Dec 5, 2018

虽然builder-webpack4已经指定版本"webpack": "^4.20.2"
但是在构建中我们的webpack版本为.feflow目录中node_modules的版本,这个版本低于4
这样会导致出现如下错误

image

相关issue已经提到是因为webpack版本问题
#webpack-contrib/mini-css-extract-plugin#69

所以我们需要找到一种方式能够让feflow使用builder中依赖的webpack,否则feflow永远只有一个版本的webpack可以用。

@LeoEatle
Copy link
Member Author

LeoEatle commented Dec 6, 2018

这个问题是因为npm会扁平化安装,导致mini-css-extract-plugin被安装到了.feflow目录下
它寻找webpack的时候,只会找到.feflow下的node_modules,而不是builder-webpack4下的。
为了避免这个问题,建议feflow可以使用--global-style来安装builder和脚手架

The --global-style argument will cause npm to install the package into your local node_modules folder with the same layout it uses with the global node_modules folder. Only your direct dependencies will show in node_modules and everything they depend on will be flattened in their node_modules folders. This obviously will eliminate some deduping.

官方文档 提到了如果想只安装到local node_modules,可以使用这个参数。

这样的话各个builder和脚手架的依赖不会互相干扰,永远优先在自己的目录下查找依赖。

@cpselvis
Copy link
Contributor

cpselvis commented Dec 6, 2018

这个方案很棒,后面feflow安装时加上这个参数,避免相互干扰

@LeoEatle
Copy link
Member Author

这个问题已经解决,close

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