84669 Lernen von Personen
152542 Lernen von Personen
20005 Lernen von Personen
5487 Lernen von Personen
7821 Lernen von Personen
359900 Lernen von Personen
3350 Lernen von Personen
180660 Lernen von Personen
48569 Lernen von Personen
18603 Lernen von Personen
40936 Lernen von Personen
1549 Lernen von Personen
1183 Lernen von Personen
32909 Lernen von Personen
相似问题:https://segmentfault.com/q/10...
比如现在我要创建一个jQuery项目,我通过
npm install jquery
将jquery安装在本地。现在我在配置文件中配置了一个HtmlWebpackPlugin自动生成一个html页面,可以将打包好的js文件直接引入到html页面中,非常方便。现在我希望, 可以将jquery直接通过script自动添加到这个自动生成的html页面中,而不需要打包,能否实现呢?
认证0级讲师
文档里不写了吗,你可以基于一个模板生成htmlhttps://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引入进来
entry: { page: 'path/to/page.js', jquery: 'node_modules/jquery/dist/jquery.min.js' }
new HtmlWebpackPlugin({ filename: 'index.html', template: 'index.html', inject: true, chunks: ['jquery', 'page'] // 按照先后顺序插入script标签 })
文档里不写了吗,你可以基于一个模板生成html
https://github.com/ampedandwi...
在模版里直接通过script标签把jquery引入进来