首页 > 如何在webpack项目中引入第三方类库?

如何在webpack项目中引入第三方类库?

相似问题:https://.com/q/10...

比如现在我要创建一个jQuery项目,我通过

npm install jquery

将jquery安装在本地。
现在我在配置文件中配置了一个HtmlWebpackPlugin自动生成一个html页面,可以将打包好的js文件直接引入到html页面中,非常方便。
现在我希望, 可以将jquery直接通过script自动添加到这个自动生成的html页面中,而不需要打包,能否实现呢?


文档里不写了吗,你可以基于一个模板生成html
https://github.com/ampedandwi...

plugins: [
  new HtmlWebpackPlugin({
    title: 'Custom template',
    template: 'my-index.ejs', // Load a custom template (ejs by default see the FAQ for details)
  })
]
<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
    <title><%= htmlWebpackPlugin.options.title %></title>
  </head>
  <body>
  </body>
</html>

在模版里直接通过script标签把jquery引入进来

【热门文章】
【热门文章】