user1
2024-06-25 ad636b07ce496716446634e59bebee05ad668db5
vue.config.js
@@ -1,14 +1,47 @@
const { defineConfig } = require("@vue/cli-service");
const webpack = require("webpack");
// 获取所有书籍列表
const bookList = process.env.VUE_APP_BOOK_LIST ? process.env.VUE_APP_BOOK_LIST.split("/") : [];
module.exports = defineConfig({
  publicPath: "./",
  publicPath: process.env.VUE_APP_PUBLIC_PATH,
  transpileDependencies: true,
  lintOnSave: false,
  // devServer: {
  //   open: true,
  //   historyApiFallback: true,
  //   allowedHosts: "all",
  //   headers: {
  //     "access-control-allow-origin": "*",
  //   },
  //   client: {
  //     overlay: { warnings: false, errors: true }
  //   }
  // },
  configureWebpack: {
    output: {
      library: `app-content`,
      libraryTarget: "umd",
      chunkLoadingGlobal: `webpackJsonp_app-content`
    }
    },
    plugins: [
      new webpack.IgnorePlugin({
        checkResource(resource) {
          if (process.env.VUE_APP_ENV == "product") {
            // 编译和打包过滤
            for (let i = 0; i < bookList.length; i++) {
              const bookName = bookList[i];
              if (bookName != process.env.VUE_APP_BOOK_ID) {
                // 过滤不需要的模块
                if (resource.indexOf(bookName) > -1) {
                  return true;
                }
              }
            }
          }
          return false;
        }
      })
    ]
  },
  chainWebpack: (config) => {
    config.module