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 聚类分析或者python进行数据分析
    • ¥15 如何用visual studio code实现html页面
    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?