douchi1945 2019-04-06 05:00
浏览 26

将脚本嵌入到类似于gulp-inject,wire-dep或webpack html插件的php页面中

just converted a project of mine from gulp to webpack 4. I have multi page set up with various entry points. Everything works great but I am unable to utilize the webpack html plugin for dependency injection as the site I am working on is running php.

Long story short I was hoping someone has some insight/advice on injecting the js bundles into a php file that are produced when I run a build utilizing webpack.

Gulp had something similar called gulp-inject which used a snippet/comment to insert scripts into an html page, grunt had something similar as well if I recall which was wire-dep.

Any advice would be greatly appreciated. Below I provided an example of what I am trying to accomplish.

Webpack config fragment:

entry: {
    landing: './js/pages/landing.js',
    about: './js/pages/about.js',
    contact: './js/pages/contact.js',
}
output: {
    filename: '[name].bundle.js',
    path: path.resolve(__dirname, 'dist')
}

In the php files I would love to do something like this or similar:

<!-- inject:js -->
<!-- js files will be automatically insert here -->
<!-- endinject -->
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?