Vue-Cli: why after the build the index.html is not generated with quotes?

僤鯓⒐⒋嵵緔 提交于 2021-02-05 09:32:01

问题


After running the npm build, the ./dist/index.html file is generated without the quotes. The project does not have a webpack.config.js or a vue.config.js. The build is generated from the example project made with vue create. How do I solve this?

<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/favicon.ico><title>html-project</title><link href=/app.css rel=preload as=style><link href=/app.js rel=preload as=script><link href=/chunk-vendors.js rel=preload as=script><link href=/app.css rel=stylesheet></head><body><noscript><strong>We're sorry but html-project doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/chunk-vendors.js></script><script src=/app.js></script></body></html>

回答1:


Attribute quotes aren't necessary there (that's still valid HTML), so they're removed in production builds to reduce the output size of the HTML file.

If you prefer to keep the quotes, you could configure the HTML minifier options (i.e., specifically removeAttributeQuotes) as follows:

// vue.config.js
module.exports = {
  chainWebpack: config => {
    config.plugin('html').tap((args) => {
      args[0].minify = {
        ...args[0].minify,
        removeAttributeQuotes: false
      }
      return args
    })
  }
}


来源:https://stackoverflow.com/questions/63638829/vue-cli-why-after-the-build-the-index-html-is-not-generated-with-quotes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!