// the key same to the value, it is not worked! return an empty object {}.
new webpack.ProvidePlugin({
'angular': 'angular'
});
// not same, it is worked!
new webpack.ProvidePlugin({
'ng': 'angular'
});
并且注意到密钥与办公室doc中的模块名称不同。
答案 0 :(得分:0)
它总体上起作用。这里的问题是,如果没有垫片,角度1与webpack不能很好地协同工作(参见https://github.com/webpack/webpack/issues/2049)。尝试这个webpack loader配置,它解决了我的问题,允许使用与模块名称相同的密钥的ProviderPlugin:
module: {
loaders: [
/*
* Necessary to be able to use angular 1 with webpack as explained in https://github.com/webpack/webpack/issues/2049
*/
{
test: require.resolve('angular'),
loader: 'exports?window.angular'
},
]
},
plugins: [
new webpack.ProvidePlugin({
'angular': 'angular',
}),
],