谁还不是小趴菜 2023-01-18 11:43 采纳率: 0%
浏览 19

vue 这个地方哪里错了,怎样修改

spring boot里vue 这个地方哪里错了为什么会说index.html有问题,怎样修改

img

img

  • 写回答

2条回答 默认 最新

  • 未来在这儿 2023-01-18 12:20
    关注

    望采纳!!! 可能是目录有中文。
    在下菜鸟一枚,最近在学习roadhog2,关于html配置项这里老是报错。
    参考1:


    参考2:
    配置了html选项之后会报错如下:
    Failed to compile.
    Error: Child compilation failed:
    Conflict: Multiple assets emit to the same filename index.html:
    Error: Conflict: Multiple assets emit to the same filename index.html

    html-webpack-plugin作用:提取html到dist文件夹,并为html文件中引入的外部资源如script、link动态添加每次compile后的hash,防止引用缓存的外部文件问题。

    参考资料之后:https://stackoverflow.com/questions/43494794/webpack-html-webpack-plugin-error-child-compilation-failed
    发现是html-webpack-plugin和fild-loader同时处理html类型文件冲突,原先使用下面方法2去解决的,但是后来发现可能会有一些未知的坑,所以现在推荐大家使用下面那个哥们的方法(方法1).

    方法1:
    修改index.html后缀为index.ejs. 然后在webpackrc.js中配置html: { template: './src/index.ejs' },

    方法2:
    1、index.html不需要放public,public文件夹会被roadhog自动copy到dist文件下,所以index.html文件放src文件夹下也可以。并且不要引入css和js文件,html-webpack-plugin插件会帮我们自动提取。

    2、 html配置项随便配置下。
    "html":{
    "template": "./src/index.html",
    "title": "myApp"
    },

    **3、重点:将roadhog配置文件build.js和dev.js修改一下下,修改目的是去掉fild-loader处理html文件,修改如下:在文件中添加一个函数过滤下。
    文件路径:roadhogDemo\node_modules\roadhog\lib\build.js
    image
    build.js和dev.js都这样搞下
    **
    再去npm start 或者build下看下。
    image
    再看下编译后的文件:/dist/index.html
    image

    评论 编辑记录

报告相同问题?

问题事件

  • 创建了问题 1月18日