LoginSignup
4
2

More than 3 years have passed since last update.

Nuxt で description をデフォルト設定していないのに、謎の値が入る

Posted at

解決策

nuxt.config.jsplugin にて meta プロパティをオフにする

 ...,
 ['@nuxtjs/pwa', { meta: false }],
 ...,

もしくは、 @nuxtjs/pwa を使わない。

前提

  • Nuxt.js v2.8.1
  • @nuxtjs/pwa

起こったこと

nuxt.config.js で、metaタグの description を設定していないのに以下のようなタグが append される

<meta data-n-head="true" data-hid="description" name="description" content="---">

原因

@nuxtjs/pwa が README.md の値を append していた

この時の README.md--- の値が使われていた。。

# Project title

---

some text...

@nuxtjs/pwa の挙動

1. package.jsondescription が設定されているとき

 package.jsondescription の値をつかって、自動的にmetaタグを挿入
 
 ※ただし、 nuxt.config.js でmetaタグが指定されていた場合は、そちらが overwrite される

2. package.jsondescription が設定されていないとき

 なぜか README.md の2行目の値が使われる 🤔🤔🤔

 中を見ると process.env.npm_package_descriptionREADME.md の値が入っていた(原因は未調査)

まとめ

PWAが要件にないのに、 @nuxtjs/pwaplugin として使われている場合は注意しましょう
 

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2