Vue3 Application died in status LOADING_SOURCE_CODE: You need to export the functional lifecycles in xxx entry

记录一下vue3qiankun踩坑

报错如标题

1、确认生命周期已经引入

确认生命周期已引入

2、确认配置是否正确

这里官方介绍比较简单,这样写的话 在webpack5.0会报错,验证不会通过
ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.output has an unknown property ‘jsonpFunction’. These properties are valid:
在这里插入图片描述
最后正确写法:

const { name } = require("./package.json");
const { defineConfig } = require("@vue/cli-service");

module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    port: 3001, // 指定端口
    headers: {
      "Access-Control-Allow-Origin": "*", // 配置跨域
      "Access-Control-Allow-Headers": "*",
      "Access-Control-Allow-Credentials": "true",
      "Access-Control-Allow-Methods": "*",
      "Cache-Control": "no-cache",
    },
    client: {
      overlay: {
        errors: true,
        warnings: false,
      }
    },
  },
  configureWebpack: {
    output: {
      library: `${name}-[name]`,
      libraryTarget: "umd",
      chunkLoadingGlobal: `webpackJsonp_${name}`,
    }
  },
});
Logo

前往低代码交流专区

更多推荐