jquery - 通过 webpack 在 head 中添加 jquery 作为单独的文件
问题描述
有没有办法将 node_modules 中的脚本(例如 jquery)作为单独的文件添加到带有 webpack 的 <head> 标记中?这是我使用 HtmlWebpackPlugin 生成模板的部分,所以我想将脚本注入所有人
let templates = fs.readdirSync('src/templates').filter(file => (path.extname(file) === '.html'))
templates.map(page => {
webpackConfiguration.plugins.push(new HtmlWebPackPlugin({
template: 'src/templates/' + page,
filename: page,
hash: true
}))
})
我知道之前在 webpack 配置中有一个名为 headerScripts 的选项,但这似乎不起作用。
解决方案
推荐阅读
- angular - IONIC 4空项目android apk文件大小大
- python - 一起循环多个生成器
- c++ - 为什么我在这里得到垃圾(不需要的)输出?
- php - 从 Json API 端点获取数据并将数据保存在数组中。基本上从从 API 回调接收到的 Json 数据创建变量
- angular - 如何修复 net::ERR_ABORTED 404(未找到)
- javascript - Jquery 在 if 语句中找不到“this”
- python - df 对具有相同日期的行进行分组
- javafx - MediaView 不显示 mp4
- spring - 在 spring-cloud SNS/SQS 监听器中获取 MessageAttributes 的问题
- python-3.x - 在没有 input() python 3的情况下要求用户输入