All Products
Search
Document Center

resource

Last Updated: Apr 12, 2022

Kylin-plugin-resource is a resource interception mechanism designed for global offline resource packages on the mPaaS platform.

Use the plug-in

The package.json file in the scaffold file contains the following configuration:

["resource", 
   {
    "map": {
      "vue": {
        "external": "Vue",
        "js": "https://gw.alipayobjects.com/as/g/h5-lib/vue/2.5.13/vue.min.js"
      },
      "fastclick": {
        "external": "FastClick",
        "js": "https://as.alipayobjects.com/g/luna-component/luna-fastclick/0.1.0/index.js"
      }
    }
  }
]

The above configuration indicates that some actions will be implemented when the following dependency statements appear:

import xxx from 'vue';
var xxx = require('vue');

When the vue dependency is used, the following actions are implemented:

  1. Inject the <script src="https://gw.alipayobjects.com/as/g/h5-lib/vue/2.5.13/vue.min.js" ></script> script resource into the generated HTML template.

  2. Redirect the preceding vue dependency to the value of window.Vue.