how to import a yaml file into a javascript file code example

Example: how to pass yaml data to vue file

// .vue file
// must have yaml-loader installed as a dependency
// place folowing block between <script></script>

import AppConfig from "@/assets/config.yaml"; // gets data from yaml config

export default {
  name: "HelloWorld",
  props: {
    msg: String,
  },
  data() {
    return {
      // can use moustaches or v-bind to dynamically inject data in template
      url: AppConfig.author["name"],
      repo: AppConfig.repo,
    };
  },
};

Tags:

Misc Example