问题
I am trying to switch from using browserify to webpack. One thing browserify handled nicely was dependency management inside dependencies. Let me give an example:
Main app project:
var util1 = require('shared-components/util1');
var util2 = require('shared-components/util2');
Inside shared-components/util1.js
var util2 = require('../util2');
Browserify would realize that the reference to util2 in both scenarios was the same but it appears that Webpack does not which creates duplicate entries for util2.
Is there a configuration setting or plugin I can use to resolve this?
回答1:
Try new webpack.optimize.DedupePlugin()
. See the docs for more info.
来源:https://stackoverflow.com/questions/31412009/webpack-creating-duplicate-entries-for-dependencies