jQuery没有在Webpack 2中加载

时间:2017-04-07 15:10:17

标签: jquery webpack-2

我正在尝试将jQuery作为我的Webpack 2构建的一部分,并且无论出于何种原因,除非我在index.html中将其添加为<script>标记,否则它似乎无法识别。< / p>

我已经完成了

require('jquery') 

在需要它的文件中

new webpack.ProvidePlugin({
  jQuery: 'jquery',
  $: 'jquery',
  jquery: 'jquery'
})

在我的webpack.config.js

以及

loaders: [
{ test: require.resolve('jquery'), loader: 'expose-loader?jQuery!expose-loader?$' }
]

我可以看到它在webpack构建中

bundle.js  2.76 MB       0  [emitted]  [big]  main
[2] ./~/lodash/index.js 408 kB {0} [built]
[8] ./~/jquery/dist/jquery.js 268 kB {0} [built]

但除非我在index.html中声明它,否则它似乎无法识别它。我错过了什么?

0 个答案:

没有答案