Home

Issue: 2373

Having a script tag inside page does not warn/error

[issue link]

First of all great job guys!
I accidentally had a script tag inside a .vue file which I didn’t notice. With the vue webpack template, you get a warning/error from the vue-template-compiler I think that there shouldn’t be a script tag inside the .vue file.

Steps to reproduce:

  1. Initialize nuxt from official nuxt template and run it locally
  2. Create a page inside pages dir which contains a script tag
<template>
  <div class="copyright">
    &copy;
    <script>
      document.write(new Date().getFullYear())
    </script>, Designed by xxx
  </div>
</template>

<script>
  export default {
    name: 'about-us'
  }
</script>

<style>

</style>
  1. Modify some text in the page.

What is expected?
Nuxt will warn/give an error that you shouldn’t have a script tag inside a .vue file.

What is actually happening?
Page hot reloads with no error but outputs only the script tag result. In this case, the current year.

I know this might sound dumb, but might be confusing for beginners who accidentally drop some scripts without knowing. After that, it might be hard to track what is happening.

This question is available on Nuxt.js community (#c2065)