1
litian
2025-04-02 f53bf74a8a938bf3d12c12b5ad460e242ed43155
vue.config.js
@@ -1,9 +1,9 @@
// const { publicCtx } = require("@/assets/js/config");
// import {publicCtx} from '@/assets/js/config'
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: 'http://182.92.203.7:3007/books/book/1',
  // publicPath:'/books/book/1',
  publicPath: process.env.VUE_APP_PUBLIC_PATH,
  transpileDependencies: true,
  lintOnSave: false,
  // devServer: {
@@ -21,8 +21,27 @@
    output: {
      library: `app-content`,
      libraryTarget: "umd",
      chunkLoadingGlobal: `webpackJsonp_app-content`,
      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
@@ -34,8 +53,8 @@
      .loader("change-prefix-loader")
      .options({
        prefix: "el-",
        replace: "gp-",
        replace: "gp-"
      })
      .end();
  },
  }
});